我想为我的文档创建页面,每个页面应该有1000个结果。

文件大小:95.000个文件

因此,从产品编号10k开始,我希望从那时起获得1K的结果,但是,使用此查询,我得到了下面提到的错误

查询:

this.es.search({
  index: indexName,
  type: type,
  from: 10000,
  size: 1000,
  body: {}
});

错误:
{
    "msg": "[query_phase_execution_exception] Result window is too large, from + size must be less than or equal to: [10000] but was [16000]. 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.",
    "path": "/products/Product/_search",
    "query": {},
    "body": "{\"from\":10000,\"size\":1000}",
    "statusCode": 500,
    "response": "{\"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 [16000]. 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\":\"products\",\"node\":\"bTGkra6dTB-0Z_8jVUNByQ\",\"reason\":{\"type\":\"query_phase_execution_exception\",\"reason\":\"Result window is too large, from + size must be less than or equal to: [10000] but was [16000]. 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}"
}

如何增加分页结果/限制?

也欢迎任何其他方法,谢谢。

最佳答案

如错误所示,Elastic将仅显示10000行。

因此要显示更多的数字,您需要使用scroll函数

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

可在此处找到带有滚动的js搜索示例。

async await with elasticsearch search/scroll

关于node.js - Elasticsearch分页自-大小结果窗口太大,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49692116/

10-12 12:32
查看更多