Add additional attributes to an existing document elasticsearch

廉价感情. 提交于 2021-02-08 12:33:30

问题


How do I add additional attributes to an existing document in Elasticsearch index.

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

This would create a document in the index. How do I add an attribute to the document? Suppose

"new_attribute":"new_value"

which would modify the document as

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

回答1:


I think it is possible with the update api. Check this :

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

and scroll down to "add a new field to the document".

Regards




回答2:


I know this is an old post but i think it can be handy

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


来源:https://stackoverflow.com/questions/18466773/add-additional-attributes-to-an-existing-document-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!