When is data actually indexed in Elasticsearch?

(Shaunak Kashyap) #1

Once the index (POST) call is made and returns, the document is guaranteed to be searchable from the index. When you query back, there are 2 ways to do it:

curl -XGET localhost:9200/myindex/order/2qLrAfPVQvCRMe7Ku8r0Tw

The above method is realtime, i.e., it will return the doc immediately after the prior POST

curl -XPOST localhost:9200/myindex/order/_search

The above method is near-realtime, i.e., it will return the doc approximately 1 second after the prior POST command. The 1 second "delay" is a called a refresh interval that can be configured per index. The default refresh interval for any index is 1 second, meaning when you run _search, documents will be included in the results 1 second after the POST command returned successfully.

If you want to refresh immediately after a document is indexed, you may also do something like (it will be a little less efficient, but it will be realtime for a succeeding _search):

curl -XPOST 'http://localhost:9200/myindex/order/2qLrAfPVQvCRMe7Ku8r0Tw?refresh=true'

(system) #2