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.
-
I am getting a a list of a user's posts from ES
-
insert a new post.
-
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.