-
问题一: 查询结果中 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);
-
问题二: 分页查询 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.]]; ...
解决方法:
修改 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 } } '
解决 Elasticsearch 分页查询记录超过10000时异常
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...