Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait for reindexing in elasticsearch?

I have an ElasticSearch with index posts setted up. I'm pushing new documents to it from time to time.

I want ElasticSearch to reply to my queries only when all documents are indexed. How can I do that?

like image 584
asiniy Avatar asked Mar 12 '23 11:03

asiniy


1 Answers

In ES 2, you can call the refresh API just after having indexed your new documents, but it's not advised to do it in production as it may decrease the performance of your cluster.

In ES5, you will be able to send your index queries with ?refresh=wait_for and ES will only respond when the new documents are ready to be searched.

like image 106
Val Avatar answered Mar 21 '23 10:03

Val