Write and then Read consistency

I am trying to achieve write and then read consistency.
In other words, once i update or insert a document, I want to immediately read it correctly.

  1. I am getting a a list of a user's posts from ES

  2. insert a new post.

  3. I would then like to do a 'GetAllPostsByUserId' and also include in that query the previously created postid.

All settings in Elasticsearch are default.

If in step 3, I do the query where I get AllPostsByUserId, and then also include in the filter the
'newly created post id', would Elasticsearch know to get the 'newly created post id' from the 'translog'.

====
For those that do not know, once you write to an index, Elasticsearch only returns once the primary and read-only replicas have also been sync via the translogs, which later gets committed to the index, after 1-2 seconds.

Here is a little trick, is that if you query via a document ID, es will first check translog, and then the index for the document, so you have perfect write-read consistency aslong as you do the 'read' part by including the id.

Mods or whoever may edit my explanation if they like.

This sounds right if your "read" operation is using the Get API since this API is realtime by default.

Ok so here is the multi get .

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