Is it possible to update any document with a key ? like we do in sql
UPDATE
table
SETgender
='male' WHEREname
=dave
Is it possible to update any document with a key ? like we do in sql
UPDATE
table
SETgender
='male' WHEREname
=dave
You have the update by query which basically does something similar
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
I tried this query
{
"script": {
"gender": "male"
},
"query": {
"match": {
"name_split": "Tim"
}
}
}
But its giving error I don't know what am I doing wrong
You did not paste the error. But I can imagine what it can be as you are not following what is written in the guide.
POST twitter/_update_by_query
{
"script": {
"inline": "ctx._source.likes++",
"lang": "painless"
},
"query": {
"term": {
"user": "kimchy"
}
}
}
BTW using a pipeline might be good as well as explained in docs:
PUT _ingest/pipeline/set-foo
{
"description" : "sets foo",
"processors" : [ {
"set" : {
"field": "foo",
"value": "bar"
}
} ]
}
POST twitter/_update_by_query?pipeline=set-foo
But may be you are just beginning with elasticsearch and you may be want to solve something else than updating a field?
I mean that if you want to update a document for which you know the id, just run:
PUT index/type/id
{
// The full content of your document here, updated
}
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.