ES查询上万条数据的时候报错问题解决方案

时间:2024-05-20 07:06:22

在使用ES查询的时候会与到一下报错,不要着急,这个是由于你的数据超过1W了 。此时应该为此高兴,说明ES可以用,并且查询速度很快。

string(1460) “{“error”:{“root_cause”:[{“type”:“illegal_argument_exception”,“reason”:“Result window is too large, from + size must be less than or equal to: [10000] but was [10005]. 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”:“books”,“node”:“FfUcBY-oQOiBqTGEe45AIA”,“reason”:{“type”:“illegal_argument_exception”,“reason”:“Result window is too large, from + size must be less than or equal to: [10000] but was [10005]. 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.”}}],“caused_by”:{“type”:“illegal_argument_exception”,“reason”:“Result window is too large, from + size must be less than or equal to: [10000] but was [10005]. 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.”,“caused_by”:{“type”:“illegal_argument_exception”,“reason”:“Result window is too large, from + size must be less than or equal to: [10000] but was [10005]. 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”:400}”

接下来我们解决这个问题:

  1. 先启动 ES_header (http://localhost:9100/) ,能看到下面的页面,当然其他的管理工具也可以。
    ES查询上万条数据的时候报错问题解决方案
    2、先关闭你使用的 索引 ,如下图

ES查询上万条数据的时候报错问题解决方案
3、进入 复合查询中
ES查询上万条数据的时候报错问题解决方案
直接复制即可,注意图中提到的。

**books/_settings?preserve_existing=true

{
“max_result_window”: “9000000”
}**