How doc_as_upsert works

I tried creating document (id=1) using PUT to /_update with "doc_as_upsert" : true and doc field. The response "result" attribute had value "created" and "version" attribute had value "1".

Again, I updated the same document with all attributes as before (id=1) using PUT to /_update with "doc_as_upsert" : true and doc field. The response "result" attribute had value "noop" and "version" attribute had value "1".

Now, I updated the same document with all attributes but one changed (id=1) using PUT to /_update with "doc_as_upsert" : true and doc field. The response "result" attribute had value "updated" and "version" attribute had value "2".

As far I understand, EL checks each attribute of the document in input against the document in index and returns response based on following:

case 1: If there is no match, it returns "noop"
case 2: If there is at least one difference, it returns "updated"
case 3: if the document doesn't exists, it creates a new document and returns "created"

How does EL handles the above behaviour? Is there any hashing performed to determine changes?
Can someone confirm that no indexing happens for case 1?

By default updates that don’t change anything detect that they don’t change anything and return "result": "noop"

Hi Dan,

Thanks for the Reply. However, I am looking for the internal logic that is used to detect changes and if someone can confirm that there is no indexing happens for case 1.

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