Java 在 Solr 中超时查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19557476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 18:18:54  来源:igfitidea点击:

Timing out a query in Solr

javasolrlucene

提问by Benjamin

I hitting queries to solr through a custom developed layer and few queries which i time out in my layer are still in the solr instance. Is there a parameter in solr which can be used to time out an particular query

我通过自定义开发的层对 solr 进行查询,而我在层中超时的一些查询仍在 solr 实例中。solr 中是否有可用于超时特定查询的参数

采纳答案by cheffe

As stated in Solr query continues after client disconnects?and written in the Solr FAQ

正如Solr 中所述,客户端断开连接后查询是否继续?写在 Solr 常见问题解答中

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.

在内部,Solr 不会对任何请求进行超时处理——它允许更新和查询需要花费多长时间才能完全处理。

But at the same spot in the FAQ is written

但是在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)

但是,用于运行 Solr 的 servlet 容器可能会对所有请求施加任意超时限制。如果您发现此值太低,请查阅您的 Serlvet 容器的文档。(在 Jetty 中,相关设置是“maxIdleTime”,以毫秒为单位)

So you may configure your container to close a long-running request so that the HTTPClients connected receive a shutdown.

因此,您可以将容器配置为关闭长时间运行的请求,以便连接的 HTTPClient 接收关闭。

However that may not be enough, Solr could internally still be working though, generating load on your Server. Therefore the common timeAllowed parametermay be used.

然而,这可能还不够,Solr 可以在内部仍然工作,在您的服务器上产生负载。因此可以使用公共 timeAllowed 参数

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.

timeAllowed - 此参数指定允许搜索完成的时间量(以毫秒为单位)。如果此时间在搜索完成之前到期,则将返回任何部分结果。

Either with each request or configured as default in your solrconfig.xml.

使用每个请求或在 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>