使用elasticsearch做分页查询时,当查询记录超过10000时,会报如下错误:
Result window is too large, from + size must be less than or equal to: [10000] but was [89120]. 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.
原因:
Elasticsearch中**index.max_result_window**默认值是10000,而我们的查询超过了这个默认值,所以就会出现上述错误。
解决办法:
需要修改一下**index.max_result_window**的值,把这个设置到合适的值即可,我这里设置100000,大家可以根据自己的需要进行设置。
PUT my_index/_settings
{
"index":{
"max_result_window":100000
}
}
设置成功后,返回"acknowledged": true