from + size must be less than or equal to: [10000] but was [10550]
from + size must be less than or equal to: [10000] but was [10550]_绅士jiejie的博客-CSDN博客
以上错误是ElasticSearch分页搜索时出现的,这是因为ES默认支持的最大条数就是10000条,深度分页导致总条数超过10000,就会报这个错。
解决方法
1.调整索引的配置项index.max_result_window,如下:
PUT index_name/_settings
{
“index.max_result_window”:10000
}
1
2
3
4
调成符合自己业务的数字即可。
2.从业务上限制
一般来说,用户搜索大多是看前几页数据就好了,毕竟有个匹配分数,越后面的匹配度越低,即使是电商商品,也不需要展示全部数据,同时深度分页性能也很差,因此很多电商网站搜索时都是展示总条数小于10000条的结果,所以我们可以设置当总条数大于10000时,强行把total设置为10000,然后前端的分页参数就再也无法请求到更深分页的数据了。
————————————————
版权声明:本文为CSDN博主「绅士jiejie」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin\_38106322/article/details/113574619
解决 Elasticsearch 分页查询记录超过10000时异常_storm_fury-CSDN博客
解决 Elasticsearch 分页查询记录超过10000时异常
storm_fury 2020-01-08 10:45:59 2238 收藏 4
分类专栏: Elasticsearch 文章标签: elasticsearch
版权
Elasticsearch
专栏收录该内容
6 篇文章1 订阅
订阅专栏
问题一: 查询结果中 hits.total.value 值最大为10000的限制
解决方法:
请求时设置 “track_total_hits”: true
Rest 请求设置方法:
curl -X POST “http://192.168.1.101:9200/my\_index/\_search?pretty“ -H ‘Content-Type: application/json’ -d’
{
“track_total_hits”: true
“query”: {
“match_all”: {}
},
“sort”: [
{
“timestamp”: {
“order”: “desc”
}
}
]
}
‘
API 设置方法:
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().trackTotalHits(true);
1
问题二: 分页查询 from 大于 10000 时的数据异常
异常信息
…
Caused by: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Result window is too large, from + size must be less than or equal to: [10000] but was [10100]. 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.]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Result window is too large, from + size must be less than or equal to: [10000] but was [10100]. 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.]];
…
1
2
3
解决方法:
修改 max_result_window 设置的最大索引值,注意以 put 方式提交
curl -X PUT “http://192.168.1.101:9200/my\_index/\_settings?pretty“ -H ‘Content-Type: application/json’ -d’
{
“index”:{
“max_result_window”:1000000
}
}
‘
————————————————
版权声明:本文为CSDN博主「storm_fury」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin\_43215250/article/details/103887106
还没有评论,来说两句吧...