ES Result window is too large, from + size must be less than or equal to: [10000] but was [10025

  • 在使用ES做分页的时候,读取超过1万条数据之后就会出现如下错误:
[HTTP/1.1 500 Internal Server Error]
{"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 [10100]. 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 .....
  • 官方文档解释
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 es索引名称/_settings  
{
  "index":{
    "max_result_window":1000000
  }
}

郝先生

继续阅读此作者的更多文章