Jack
Jack

Reputation: 5880

elastic search latency of index/update

I have the 3 steps transaction as the following:

(1)Insert User basic info(id,name).
(2)Search the User Id. 
(3)If found the user,then update the record with user behavior info.

So I used elasticSearch.index() API to insert the user id and name, then elasticSearch.search() API to query it, if found, I will update the record via elasticSearch.update() API. But the ES latency cause the search() API got nothing even though the data already was indexed. So any ideas about fixing this please, thanks!

Upvotes: 1

Views: 1359

Answers (1)

Val
Val

Reputation: 217314

By default the index is refreshed every second, but you can use the Refresh API to force a refresh and make sure the newly indexed data is available.

curl -XPOST 'http://localhost:9200/users/_refresh'

Note that it is ok to call this for testing purposes, but you should not do this on your production cluster as it may cause performance issues.

Upvotes: 1

Related Questions