How to get more than 10 thousand Documents at a time from Elasticsearch Using Jest client

淺唱寂寞╮ 提交于 2019-12-12 02:08:50

问题


ElasticSearch by-default gives 10 records, but we can set the size parameter and can get the more than 10 records but there is limit, we can set only 10000 as record size if we use Jest client for Elasticsearch, if its more than 10 thousand then throws Exception.

please help me to get more than 10 thousand records at once in elasticsearch using jest client(java)

Thanks in Advance


回答1:


That limit is there for a reason — quoting from the documentation:

The index.max_result_window which defaults to 10,000 is a safeguard, search requests take heap memory and time proportional to from + size.

Depending on your use-case, there are better alternatives:

  • Real-time / user facing: Use Search After (and avoid deep pagination) with good response times and reasonable heap usage.
  • Machine / batch processing (often to read all data): Scroll, which creates a search context and keeps it open for the specified amount of time. The result will also be stable as long as the context is open.



回答2:


You can update the max-result window of elasticsearch.

curl -XPUT "http://localhost:9200/my_index/_settings" -d '{ "index" : { "max_result_window" : 500000 } }'

But this will only be persisted until Elastic is restarted. You can make a change

index.max_result_window: 1000000

in elasticsearch.yml file for permanent solution.



来源:https://stackoverflow.com/questions/42972508/how-to-get-more-than-10-thousand-documents-at-a-time-from-elasticsearch-using-je

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!