If I understand correctly, do you want to index the document, but only if it already exists? How is the op_type update option?
You can mainly use this with the update API, given that your mapping remains unchanged. With _update , if the document does not exist, you will return to 404 . If it exists, ES will merge the contents of the doc with any document. If you make sure that you send a new document with all the fields in the mapping, you are actually replacing it directly.
Note, however, that you can do this without merging the document quite effectively in two queries; the first of which checks for the existence of a HEAD request document. If HEAD /idx/type/id successful, execute a PUT . This, in fact, is what happens inside the company anyway with the update API, with a little extra overhead. But HEAD really cheap because it does not shuffle any payload. It just returns HTTP 200/404.
drewr source share