2016-03-30 10 views
0
var settings = new ConnectionSettings(Constants.ElasticSearch.Node); 
var client = new ElasticClient(settings); 

var response = client.Search<DtoTypes.Customer.SearchResult>(s => 
    s.From(0) 
    .Size(100000) 
    .Query(q => q.MatchAll())); 

サイズが小さい場合に機能しますが、100,000を超えるドキュメントを持つインデックスのすべてのドキュメントを取得したいとします。制限を回避するために欠落している構成設定である必要があります。私はまた、デバッグ情報の代わりにSize()Nest v。2.1を使用してElasticSearchですべてを照会

Take()を試され

"Invalid NEST response built from a unsuccesful low level call on POST: /_search\r\n# Audit trail of this API call:\r\n - BadResponse: Node: http://127.0.0.1:9200/ Took: 00:00:00.2964038\r\n# ServerError: ServerError: 500Type: search_phase_execution_exception Reason: \"all shards failed\"\r\n# OriginalException: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.\r\n at System.Net.HttpWebRequest.GetResponse()\r\n at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\users\russ\source\elasticsearch-net\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 138\r\n# Request:\r\n\r\n# Response:\r\n\r\n"

+0

デバッグ情報は、クエリ中にelasticsearch内で何かが起こっているように見えます。通常の検索APIで実行してみましたか?あなたはネストレスポンスから 'response.RequestInformation'でもクエリーを取得できるはずです – BenM

+0

たぶん[this](http://stackoverflow.com/questions/27955623/is-there-a-way-to-retrieve -all-records-in-a-elasticsearch-nest-query)の答えが役に立ちます。 – Rob

+0

'ConnectionSettings'で' .DisableDirectStreaming() 'を実行すると、' DebugInformation'でリクエストとレスポンスを見ることができます(_DisableDirectStreaming()を使用したいのですが、 in production_) –

答えて

1

Elasticsearchはそれを返すことができます結果の量のソフト制限を持って戻ってきました。

"Note that from + size can not be more than the index.max_result_window index setting which defaults to 10,000. See the Scroll API for more efficient ways to do deep scrolling."

参考:

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html https://nest.azurewebsites.net/nest/search/scroll.html

あなたが一度でもっとして10.000結果が必要な場合は、スキャンし、スクロール機能:) Elasticsearchのドキュメントから

を使用する必要があります

+0

私はそれを試してみます。私の古いテストでは、Nestを使ってTake(100000)を設定していましたが、それはうまくいったので、値を増やすためにその設定をしておく必要があります。上記のリンクから、「スクロールはリアルタイムのユーザ要求ではなく、大量のデータ "となる。私は、すべてを引き出すために自分のデータの全体のメモリ内のキャッシュを持つことになるかもしれません実際の検索のための弾性を使用して –

+0

あなたの古いテストは、Elasticsearchの古いバージョンに対して実行されましたか?私が正しく覚えていれば、彼らは2.xのどこかに限界を導入しました。私はあなたのユースケースが何であるかはわかりませんが、一度に100,000の結果が返される必要がありますか? –

+0

私はそれが2.xだと思った。私はおそらく設定ファイルのindex.max_result_window_indexを何かばかげて設定しました。ええ...会社の所有者が望んでいる、会社の所有者が取得:)私はすでにそれに対して私のケースを作った。 –

関連する問題