Joa,

To allow an existing document to be updated, replaced, or deleted, 
ElasticSearch implements the following behaviors:

1. Internal version numbers for a document start at 1 and increment by one 
after each update to a document. When indexing or deleting an existing 
document, an internal version number must match the document's version or 
the operation will be rejected.

2. External version numbers for a document start at whatever value is 
specified by the application. When indexing or deleting an existing 
document, an external version number must be greater than the document's 
version or the operation will be rejected. When the operation completes 
successfully, the document's version will be the externally specified 
version number.

So, to safely update part of a document, the best approach that comes to 
mind is to use internal versioning and then:

1. When you have the existing document you wish to update, keep its 
original contents and its version number: current-doc, let's say.

2. Keep your updates in a separate document: updated-doc, let's say.

3. Merge updated-doc into current-doc to generate a new document. new-doc, 
let's say. It has the same version number as current-doc.

4. If the update of new-doc fails with a version check, then re-read the 
current document (saving its new version number) into current-doc, and 
repeat step 3 until success or some configured limit.

In essence, it's a very nice way to let versioning ensure that updates 
across different sources are non-destructively merged. ES rocks!

Does this help?

Brian

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/6b0c7d35-b71a-41e6-a95f-8b69d4798e3c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to