gpt4 book ai didi

elasticsearch - 当我们在插入文档时未明确添加_id字段时,elasticsearch是否确保_id字段是唯一的

转载 作者:行者123 更新时间:2023-12-03 01:38:45 33 4
gpt4 key购买 nike

我有一些 Elasticsearch 索引,在其中我需要使_id字段在所有索引中保持唯一,因为我需要在其他索引文档中使用相同的引用作为引用,如果我未明确定义_id字段,是否可以确保所有索引的唯一性,类似于mongodb _id字段,该字段在所有集合中都是唯一的(mongodb通过使用时间戳概念来做到这一点)
对于EX-当我创建 Elasticsearch 文档并且未明确定义_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"


}
}
]
}
}

最佳答案

是的,它在Elasticsearch 6.x及更高版本中是唯一的。
对于以前的版本<6.x。它是_uid(_type和_id的组合)

Es official link

关于elasticsearch - 当我们在插入文档时未明确添加_id字段时,elasticsearch是否确保_id字段是唯一的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49842176/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com