問題描述
我通過自定義開發(fā)層對 solr 進(jìn)行查詢,并且在我的層中超時的少數(shù)查詢?nèi)栽?solr 實例中.solr 中是否有一個參數(shù)可以用來使特定查詢超時
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 查詢是否繼續(xù)? 和 寫在 Solr 常見問題解答中
在內(nèi)部,Solr 不會對任何請求進(jìn)行超時 - 它允許更新和查詢都需要花費多長時間才能完全處理.
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.
但在常見問題解答中的同一位置寫入
But at the same spot in the FAQ is written
但是,用于運行 Solr 的 servlet 容器可能會對所有請求施加任意超時限制.如果您發(fā)現(xiàn)此值太低,請查閱您的 Serlvet 容器的文檔.(在 Jetty 中,相關(guān)設(shè)置是maxIdleTime",以毫秒為單位)
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)
因此,您可以將容器配置為關(guān)閉長時間運行的請求,以便連接的 HTTPClients 接收關(guān)閉.
So you may configure your container to close a long-running request so that the HTTPClients connected receive a shutdown.
但這可能還不夠,但 Solr 內(nèi)部可能仍在工作,在您的服務(wù)器上產(chǎn)生負(fù)載.因此可以使用常用的timeAllowed參數(shù).
However that may not be enough, Solr could internally still be working though, generating load on your Server. Therefore the common timeAllowed parameter may be used.
timeAllowed - 此參數(shù)指定允許完成搜索的時間量(以毫秒為單位).如果此時間在搜索完成之前到期,將返回任何部分結(jié)果.
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 中配置為默認(rèn)值.
Either with each request or configured as default in your 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>
這篇關(guān)于Solr 中的查詢超時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!