Elasticsearch(es)查询报错:Result window is too large, from + size must be less than or equal to: [10000] but was [20000

发布时间 2023-04-03 10:32:45作者: yvioo

 

{"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 [20000]. 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":"export","node":"scF9aemwTUuv9t0jPF0PrA","reason":{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [20000]. 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}

 

es默认只能查询一万条,超过条数限制就需要设置索引

修改索引设置

PUT export/_settings
{
  "index.max_result_window":100000
}

export是索引名称 ,上面表示修改查询限制为十万条

es不要查询大数据量,会很消耗内存