【问题标题】:Add additional attributes to an existing document elasticsearch向现有文档弹性搜索添加其他属性
【发布时间】:2013-08-30 06:42:30
【问题描述】:

如何向 Elasticsearch 索引中的现有文档添加其他属性。

$ curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'

这将在索引中创建一个文档。如何向文档添加属性? 假设

"new_attribute":"new_value"

这会将文档修改为

"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
"new_attribute" :"new_value"

【问题讨论】:

    标签: indexing elasticsearch document updating


    【解决方案1】:

    我认为更新 api 是可能的。 检查这个:

    https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_update_part_of_a_document

    并向下滚动以“向文档添加新字段”。

    问候

    【讨论】:

    • 我的错。没仔细看文档。非常感谢。
    • 这个链接失效了,新的api文档在这里:ES Update API
    【解决方案2】:

    我知道这是一篇旧帖子,但我认为它可以很方便

    POST /twitter/tweet/1/_update
    {
      "doc": {
        "new_attribute":""
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 2022-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-19
      相关资源
      最近更新 更多