I have a rdbms table design which are one to many relation.
Under some consideration,we decide put the relation into elasticsearch index.
I create a index(for parent table) and a nested field for the child table.
Everything works fine until the tough "phantom Read" problem occur as below.
Our requirement is that some field in the nested object need to be unique across documents,
So I need to check the value of the field before adding a new nested object.
Because the verification and insert action are seperate Elasticsearch API,it may cause the "phantom read" due to the other concurrent insertion request.
Following the Optimistic concurrency control,we use the if_seq_no and if_primary_term to avoid the problem.
But the unique field in nested object is across all documents and every document has its own seq_no and primary_term,How do I assure it won't happen "phantom read" when just adding a nested object into one document?
I also notice that the meta field "version" of document Versioning,can I also use version for concurrency control?
Or concurrency control of seq_no and primary_term can be used in distributed elasticsearch node and version field just for one node?