Does update and query document in diff cache?

step:

  1. updated document
  2. query the document immediately

expected:
return latest of the document

but
retunr the old docment

Does update and query document in diff cache? update in RAM CACHE and QUERY IN DISK ?

This is expected and has nothing to do with caching. When a document is indexed it is written to the transaction log. At this point it is safely stored but not yet searchable. Elasticsearch stores searchable data in immutable segments, and as these are relatively expensive to create, so for performance reasons they are only generated periodically based on data in the transaction log. By default this happens once per second, which is why the data does not immediately show up in searches. You can read more about this here.

What @Christian_Dahlqvist is describing is absolutely correct for _search you can immediately read the document by _id as soon as as the index operation is finished.

GET my-index/_doc/<document _id>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.