使用elasticSearch做分页时,提示如下:
org.elasticsearch.search.query.QueryPhaseExecutionException: Result window is too large, from + size must be less than or equal to: [10000] but was [20385]. 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.
字面意思是:查询结果太大,最多只能查询到10000条。
查了下es的文档,确实如此:
index.max_result_window
The maximum value of from + size for searches to this index.
Defaults to 10000. Search requests take heap memory and time proportional to from + size and this limits that memory.
See Scroll or Search After for a more efficient alternative to raising this.
不过这个可以通过修改索引的设置来改动上线:
PUT my_index/_settings
{
"index":{
"max_result_window":1000000
}
}
这里设置为1000000最大,继续操作则没有问题了。