David and Brian, thanks for you answers. Brian, that might work, but its a lot of code for a simple counter update. I hoped that there would be a flag like keepVersionNumber = true as parameter when updating.
Do you think this might be a reasonable feature request or does it make no sense at all? On Friday, January 17, 2014 4:15:23 PM UTC+1, InquiringMind wrote: > > 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/b98cdc35-b66e-491a-af35-5cc0c092c924%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.