java - 在 Solr 中超时查询

标签 java solr lucene

我通过自定义开发层查询到 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/

相关文章:

java - 如何在SOLR中处理突出显示片段中的html标签

date - 在 solr 中使用 facet.date 和 stats.facet

Java Streams 列表将出现的索引映射为键

java - JAVA 中的 equals() 方法

java - Solr执行DataImportHandler时出现java.lang.ClassNotFoundException : net. minidev.json.writer.JsonReaderI

java - lucene 上的正则表达式查询是如何工作的?

php - 如何使用ElasticSearch索引搜索单词的一部分

java - 在lucene中添加对象列表

Javascript 与 Java - 字符串编码

java - 对私有(private)列表问题的迭代