1 修改 max_result_window

1.1 概述

Elasticsearch默认max_result_window的值是10000,既然都用到Elasticsearch,那么我们的数据就会远远超过这个值,这时候,我们在查询时,就会报错,提示我们:

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 [1253670]. See the scroll api for a more efficient way to request lar

我们只需要将max_result_window的值改大一些,就就可以了。

1.2 修改方式

PUT http://192.168.3.200:9200/索引/_settings
Content-Type application/json
参数:

  1. {
  2. "index.max_result_window": 目标数
  3. }

响应:

  1. {
  2. "acknowledged": true
  3. }

1.3 验证修改结果

GET http://192.168.3.200:9200/索引/_settings
响应:

  1. {
  2. "spring-boot-elasticsearch-sample-phone": {
  3. "settings": {
  4. "index": {
  5. "refresh_interval": "1s",
  6. "number_of_shards": "1",
  7. "provided_name": "spring-boot-elasticsearch-sample-phone",
  8. "max_result_window": "1000000000",
  9. "creation_date": "1594224321383",
  10. "store": {
  11. "type": "fs"
  12. },
  13. "number_of_replicas": "1",
  14. "uuid": "pbgehnfyQcanClWPM40QiA",
  15. "version": {
  16. "created": "7070099"
  17. }
  18. }
  19. }
  20. }
  21. }