How to create unique constraint in Elasticsearch database?

前端 未结 5 1595
别那么骄傲
别那么骄傲 2020-12-01 18:02

I am using elasticsearch as a document database and each record I create has a guid id that the system uses for the record id. Business people want to offer a feature to let

5条回答
  •  一生所求
    2020-12-01 19:04

    Another approach might be to generate the string you store in a field that should be unique by integrating an auto-incrementing integer. This way you ensure from the start that your field values are unique.

    You would put your file name together like this:

    _
    

    Auto-incrementing integers are not supported by Elasticsearch per se but you could mimic them using this approach. If you happen to use node.js you can use the es-sequence module.

提交回复
热议问题