gpt4 book ai didi

elasticsearch - 如何在 elasticsearch 2.0 中设置 _id

转载 作者:行者123 更新时间:2023-11-29 02:45:49 25 4
gpt4 key购买 nike

由于不推荐在特定映射的 _id 字段上配置 path(如文档 here 中所述),

如何在 elasticsearch 2.0 中为特定文档设置 _id 字段?

(在我的特定用例中,我想用我自己的 ID 索引所有文档。我知道它们都是唯一的)

最佳答案

_id 被弃用仅仅意味着您必须明确指定 id 并且 ES 不会让您第一次解析您的文档只是为了检索您指定为 id 字段的字段.

因此,只要您明确指定 id,所有当前索引文档的方法仍然有效:

curl -XPUT localhost:9200/index/type/your_id -d '{"field1": "value1"}'
^
|
your id goes here

或在批量查询中

curl -XPOST localhost:9200/_bulk -d '
{"index": {"_index": "index", "_type": "type", "_id": "your_id"}}
{"field1": "value1"} ^
' |
your id goes here

关于elasticsearch - 如何在 elasticsearch 2.0 中设置 _id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32334709/

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