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分頁搜索時出現(xiàn)的,這是因?yàn)镋S默認(rèn)支持的最大條數(shù)就是10000條,深度分頁導(dǎo)致總條數(shù)超過10000,就會報這個錯。
解決方法
1.調(diào)整索引的配置項(xiàng)index.max_result_window,如下:
PUT index_name/_settings
{
? "index.max_result_window":10000
}
1
2
3
4
調(diào)成符合自己業(yè)務(wù)的數(shù)字即可。
2.從業(yè)務(wù)上限制
一般來說,用戶搜索大多是看前幾頁數(shù)據(jù)就好了,畢竟有個匹配分?jǐn)?shù),越后面的匹配度越低,即使是電商商品,也不需要展示全部數(shù)據(jù),同時深度分頁性能也很差,因此很多電商網(wǎng)站搜索時都是展示總條數(shù)小于10000條的結(jié)果,所以我們可以設(shè)置當(dāng)總條數(shù)大于10000時,強(qiáng)行把total設(shè)置為10000,然后前端的分頁參數(shù)就再也無法請求到更深分頁的數(shù)據(jù)了。
————————————————
版權(quán)聲明:本文為CSDN博主「紳士jiejie」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接: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 文章標(biāo)簽: elasticsearch
版權(quán)
Elasticsearch
專欄收錄該內(nèi)容
6 篇文章1 訂閱
訂閱專欄
問題一: 查詢結(jié)果中 hits.total.value 值最大為10000的限制
解決方法:
請求時設(shè)置 "track_total_hits": true
Rest 請求設(shè)置方法:
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 設(shè)置方法:
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().trackTotalHits(true);
1
問題二: 分頁查詢 from 大于 10000 時的數(shù)據(jù)異常
異常信息
...
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 設(shè)置的最大索引值,注意以 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
? }
}
'
?
————————————————
版權(quán)聲明:本文為CSDN博主「storm_fury」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_43215250/article/details/103887106
總結(jié)
以上是生活随笔為你收集整理的from + size must be less than or equal to: [10000] but was [10550]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IDEA导入Eclipse项目
- 下一篇: stream获取filter