Define custom unique key

Hi team,

Is there a way to define our own custom unique key for the document which is similar to uniqueKey provided in Solr.

For e.g I need to define employeeId or a combination of 2 fields as unique id.

Any example would be really helpful


Welcome to our community! :smiley:

You can create your own field (key) with a unique ID if you want.

Hi @warkolm :

Thanks for you reply.

Please help me understand this better.

Say suppose I want to define empid as a uniquekey. This way I want to prevent insertion of another user with the same empid. There should be only one unique empid in ES, duplicates should get rejected.

You can set this empid as the Elasticsearch _id, but if you send an update it will overwrite the existing document.

So Elasticsearch won't reject the request, it's something your code needs to check and enforce.

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