首页 > 解决方案 > ElasticSearch 无法返回超过 10,000 偏移量的数据,我不允许更改索引级别。无法使用滚动 API

问题描述

我正在逐步运行 ES 查询以获取不同的偏移量和限制。例如 100 到 149,然后 150 到 199,然后 200 到 249.. 等等。当我保持偏移+限制超过 10,000 时,就会低于异常:

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

我知道我们可以通过增加“max_result_window”来解决这个问题。我试过了,它也有帮助。我将其增加到 15,000 和 30,000。但我不允许更改索引级别。所以,我把它改回默认的一万。

我怎么解决这个问题?此查询受到 API 调用的影响。

标签: elasticsearch

解决方案



推荐阅读