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"
DescriptioneditEnables you to script document updates. The script can update, delete, or skip modifying the document. The update API also supports passing a partial document, which is merged into the existing document. To fully replace an existing document, use the index API.
The best way to add data to the Elastic Stack is to use one of our many integrations, which are pre-packaged assets that are available for a wide array of popular services and platforms. With integrations, you can add monitoring for logs and metrics, protect systems from security threats, and more.
If a search request results in more than ten hits, ElasticSearch will, by default, only return the first ten hits. To override that default value in order to retrieve more or fewer hits, we can add a size parameter to the search request body.
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
I know this is an old post but i think it can be handy
POST /twitter/tweet/1/_update
{
"doc": {
"new_attribute":""
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With