【问题标题】:Does elasticsearch ensures _id field is unique when we do not explicitly add that while inserting a document当我们在插入文档时没有明确添加时,弹性搜索是否确保 _id 字段是唯一的
【发布时间】:2018-04-15 12:58:03
【问题描述】:

我有一些弹性搜索索引,我需要在所有索引中保持 _id 字段的唯一性,因为我需要在其他索引文档中使用相同的参考,如果我没有明确定义 _id 字段,它是否确保唯一性在所有索引中,类似于 mongodb _id 字段的东西在所有集合中都是唯一的(mongodb 通过使用时间戳概念来做到这一点) 对于 EX - 当我创建弹性搜索文档并且没有明确定义 _id 时,我在 _id 字段中获取了数据 喜欢

{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "app",
        "_type": "app",
        "_id": "8kznyGIBd_HxFbiV_E89",
        "_score": 1,
        "_source": {
          "appfield": "5dc0f6ea00b2665a682f865b",
          "secretfield": "6a7d75798d1fc93107381d6f"


        }
      }
    ]
  }
}

【问题讨论】:

  • 是的,自动生成的 Id 字段是一个指南,所以它是唯一的

标签: elasticsearch


【解决方案1】:

是的,它在 Elasticsearch 6.x 及更高版本中是独一无二的。 对于以前的版本

Es official link

【讨论】:

    猜你喜欢
    • 2021-07-01
    • 1970-01-01
    • 2018-08-26
    • 2020-03-24
    • 1970-01-01
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多