我通过自定义开发层查询到 solr,我在我的层中超时的几个查询仍在 solr 实例中。 solr中是否有一个参数可用于使特定查询超时
最佳答案
如 Solr query continues after client disconnects? 中所述和 written in the Solr FAQ
Internally, Solr does nothing to time out any requests -- it lets both updates and queries take however long they need to take to be processed fully.
但在 FAQ 的同一位置写着
However, the servlet container being used to run Solr may impose arbitrary timeout limits on all requests. Please consult the documentation for your Serlvet container if you find that this value is too low. (In Jetty, the relevant setting is "maxIdleTime" which is in milliseconds)
因此,您可以配置您的容器以关闭长时间运行的请求,以便连接的 HTTPClients 收到关闭消息。
然而,这可能还不够,Solr 可能仍然在内部工作,在您的服务器上产生负载。因此the common timeAllowed parameter可以使用。
timeAllowed - This parameter specifies the amount of time, in milliseconds, allowed for a search to complete. If this time expires before the search is complete, any partial results will be returned.
无论是针对每个请求还是在您的 solrconfig.xml 中配置为默认值。
<requestHandler name="standard" class="solr.StandardRequestHandler" default="true">
<lst name="defaults">
<!-- other parts left out -->
<!-- timeout (in milliseconds) -->
<int name="timeAllowed">5000</int>
</lst>
</requestHandler>
关于java - 在 Solr 中超时查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19557476/