[英]Elasticsearch Pagination From - Size Result window is too large
I would like to have pages for my documents, each Page should have 1000 results. 我想为文档创建页面,每个页面应该有1000个结果。
Documents size: 95.000 docs 文件大小:95.000个文件
So starting from product number 10k, I would like to have 1K results from that point, however, using this query, I got the error mentioned below 因此,从产品编号10k开始,我希望从那时起获得1K的结果,但是,使用此查询,我得到了下面提到的错误
Query: 查询:
this.es.search({
index: indexName,
type: type,
from: 10000,
size: 1000,
body: {}
});
Error: 错误:
{
"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}"
}
How can I increase the paging result/ limit? 如何增加分页结果/限制?
Also any other method is welcome, thank you. 也欢迎任何其他方法,谢谢。
Based on elasticsearch documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html 基于elasticsearch文档https://www.elastic.co/guide/zh-cn/elasticsearch/reference/current/search-request-from-size.html
Note that from + size can not be more than the index.max_result_window index setting which defaults to 10,000 请注意from + size不能大于index.max_result_window索引设置,该设置默认为10,000
As alternative, you can try to use scroll
or searchAfter
. 或者,您可以尝试使用scroll
或searchAfter
。 For more real-time query, searchAfter
is more suitable. 对于更实时的查询, searchAfter
更合适。
Scroll documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html 滚动文档https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/search-request-scroll.html
SearchAfter documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html SearchAfter文档https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/search-request-search-after.html
As the error shows Elastic will only display 10000 rows. 如错误所示,Elastic将仅显示10000行。
so to display more than that number you need to use the scroll
function 因此要显示更多的数字,您需要使用scroll
功能
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
An example of a js search with scroll can be found here. 可在此处找到带有滚动的js搜索示例。
async await with elasticsearch search/scroll 用Elasticsearch搜索/滚动异步等待
好吧,我可以使用此CURL增加分页的限制
curl -XPUT "http://localhost:9200/my_index/_settings" -d '{ "index" : { "max_result_window" : 500000 } }'
Increase max_result_window
as below, it works 增加max_result_window
如下,它的工作原理
PUT indexName/_settings
{
"index": {
"max_result_window": 10000000
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.