Reputation: 18521
After I insert a document to ElasticSearch I immediately go and retrieve it with a query. I am polling the request several times so if it isn't completely indexed it will return in the second or third try.
Sometimes, in a clustered environment, I have noticed that I can get the request and a milisecond later the same request is returned empty.
I assume that it goes to another node in the cluster - that is not yet indexed.
If this is it, I really need to define the cluster to return a value only after all nodes are updated with it.
Thanks.
Upvotes: 1
Views: 54
Reputation: 217274
What you're experiencing is normal given Elasticsearch works in "near-real" time. By default, the cluster is refreshed every second, but you can change that in the configuration if you need to perform refreshes more often. Doing so you run the risk of putting your cluster under a heavy load.
An alternative way if you want the result of your indexing operation to be available for the next call, is to explicitly refresh your cluster and only then issue a search request.
PUT /my_index/doc/1
POST /my_index/_refresh
POST /my_index/_search
Upvotes: 1