问题
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