How to create unique constraint in Elasticsearch database?

前端 未结 5 1598
别那么骄傲
别那么骄傲 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 18:48

    So far as to ES 7.5, there is no such extra "constraint" to ensure uniqueness using a custom field in the mapping.

    But you still can walk around it via your own application UUID, which could be used directly explicitly as the _id (which is unique implictly) to achieve your goals.

    PUT /_doc/
    {
      "a_field": "a_value"
    }
    

提交回复
热议问题