ElasticSearch index.max_result_window

当用elasticsearch进行深度分页查询时的size-from大于10000的时候,就会报错“org.elasticsearch.search.query.QueryPhaseExecutionException”,

Caused by: org.elasticsearch.search.query.QueryPhaseExecutionException: Result window is too large, from + size must be less than or equal to: [10000] but was [19998]. 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.
        at org.elasticsearch.search.DefaultSearchContext.preProcess(DefaultSearchContext.java:206) ~[elasticsearch-6.1.1.jar!/:6.1.1]
        at org.elasticsearch.search.query.QueryPhase.preProcess(QueryPhase.java:90) ~[elasticsearch-6.1.1.jar!/:6.1.1]
        at org.elasticsearch.search.SearchService.createContext(SearchService.java:564) ~[elasticsearch-6.1.1.jar!/:6.1.1]
        at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:528) ~[elasticsearch-6.1.1.jar!/:6.1.1]
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:324) ~[elasticsearch-6.1.1.jar!/:6.1.1]
        at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:310) ~[elasticsearch-6.1.1.jar!/:6.1.1]
        ... 9 common frames omitted

解决办法有三:

  1. 对于单个索引使用
curl -XPUT host:port/indexName/_settings -H 'Content-Type: application/json' -d '{ "index.max_result_window" :"1000000"}'
  1. 对于全部索引使用
curl -XPUT host:port/_settings -H 'Content-Type: application/json' -d '{ "index.max_result_window" :"1000000"}'
  1. 在配置文件elasticsearch.yml中修改
index.max_result_window: 1000000

你可能感兴趣的:(ElasticSearch index.max_result_window)