2017-12-18 10 views
1

私はelasticsearch-rails gemを使用しています。Ruby on Rails - ElasticSearch Resultウィンドウが大きすぎます

ページ区切りの上位ページ番号のリンクをクリックすると、次のエラーが表示されます。ここにエラーがあります:

Elasticsearch::Transport::Transport::Errors::InternalServerError ([500] {"error":{"root_cause":[{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [48700]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"products","node":"fNcaDjwzRRGu2fq0KjTWUQ","reason":{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [48700]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}}]},"status":500}): 

ここで私はindex.max_result_windowを設定しますか、これはこの問題を解決する正しい方法ですか?

+1

[Elasticsearch 2.1:結果ウィンドウが大きすぎます(index.max \ _result \ _window)]の重複している可能性があります(https://stackoverflow.com/questions/35206409/elasticsearch-2-1-result-window-is- too-large-index-max-result-window) –

+0

@ThomasEdwards私はelasticsearch-restの宝石ではなく、elasticsearch-railsの宝石を使用しています。 –

+1

ああ、https://medium.com/@thecolorfulcrayon/configuring-elasticsearch-on-rails-8bcbe973e9e7は、app/config/initializersでelasticsearch.rbを作成し、そこに設定を提案しています –

答えて

1

本当にユーザーが48000項目のページを変更できるようにする必要がありますか?ここでの問題は、elasticsearchが内部でどのように動作するかにあります。 N個の結果をクエリすると、elasticsearchは最初のN-1個の結果をフェッチして破棄しなければなりません。だからこそ、このようなクエリは、ページングの深いユーザーほど高価になります。

スクロールAPIは、ごく少数のユーザーしかなく、すべてが動作している(同時に多数のスクロールコンテキストを開いていないなど)場合があります。

オプションの場合は、これらの10k結果にページング数を制限し(さらに少なくします)、ユーザーのクエリをより具体的にするようおすすめします。そうでない場合は、クラスタのハードウェア(メモリ!)に準備し、長時間実行しているクエリを実行してください。

+0

ページネーションを制限することに決めました。各ページの25レコードで400ページにページ分割を制限しました。ちょうどうまく動作するようです。ありがとう! –