Elasticsearch-js: Document not found immediately after it is saved

Created on 29 Jun 2015  路  4Comments  路  Source: elastic/elasticsearch-js

Searching for a document immediately after it is saved, i.e. searching for it in its callback/promise will give you no matching results. For example:

client.create({
  ...
}).then(function (res) {
  client.search({ ... }) // no matching results
});

Wildcard query string '*' results in list of matching entries but newly created document missing from that list.

I tried searching after a slight delay (500ms) and the search did come back with the newly saved document.

Most helpful comment

Elasticsearch by default refreshes each shard every 1s, so the document will be available to search 1s after indexing it.

Search for index.refresh_interval on the indicies settings page. You'll want to set that to either something low or manually call refresh after indexing the document.

All 4 comments

Elasticsearch by default refreshes each shard every 1s, so the document will be available to search 1s after indexing it.

Search for index.refresh_interval on the indicies settings page. You'll want to set that to either something low or manually call refresh after indexing the document.

Nice; I will try that later this afternoon and update this ticket accordingly.

I see that the JS client has a way to manually refresh indices, but is there a way to pass in the configuration for refresh_interval on client instantiation?

On second thought it seems that it would make better sense to set refresh_interval server-side than client side

So you can set it in the server-side config if this is going to be your use-case, but I'd recommend manually refreshing the index if you're not making a lot of these requests.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaustavghosh06 picture kaustavghosh06  路  5Comments

peshrawahmed picture peshrawahmed  路  3Comments

mojzu picture mojzu  路  4Comments

ev0065 picture ev0065  路  3Comments

rtercias picture rtercias  路  4Comments