Index document only if document does not exist

Hi,

Is there a way to index a document only if the document does not already exist? For instance, if I have a setup where I have configured the UUID (a field in my document) to be the document identifier, is there a flag (or some other mechanism) that if I perform two inserts then only one insert will succeed (and perhaps the other will throw, ideally soemthing like 'document already exists exception')?

Cheers,
EuclideanSearch

Yes, look into the op_type option.

The index operation also accepts an op_type that can be used to force a create operation, allowing for "put-if-absent" behavior. When create is used, the index operation will fail if a document by that id already exists in the index.

2 Likes

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