解决ES中查询结果超过10000条报错

在ES中查询结果超过10000条的时候,会报出如下错误:

{
    "error": {
        "root_cause": [
            {
                "type": "query_phase_execution_exception",
                "reason": "Result window is too large, from + size must be less than or equal to: [1000000] but was [10000010]. 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 parameter."
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "results",
                "node": "JwHV4B5VSN-F9US2cNmXZA",
                "reason": {
                    "type": "query_phase_execution_exception",
                    "reason": "Result window is too large, from + size must be less than or equal to: [1000000] but was [10000010]. 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 parameter."
                }
            }
        ]
    },
    "status": 500
}

默认只能查到一万条,将该设置增大即可。

解决方法:

curl -XPUT http://127.0.0.1:9200/results/_settings -d '{ "index" : { "max_result_window" : 1000000}}'

注意:上面url中的results换成自己的index名称

或者在postman中发送put请求也可以。报文如下:

{ "index" : { "max_result_window" : 1000000}}

你可能感兴趣的:(ES)