Reputation: 821
I am trying to run update by query
on my elasticsearch index using the method provided in this answer. This is the query that I've been trying to run:
curl -XPOST 'localhost:9200/my_index/_update_by_query' -d '
{
"query":{
"match":{
"latest_uuid":"d56ffe2095f511e6bcdd0acbdf0298e3"
}
},
"script" : "ctx._source.is_in_stock = \"false\";"
}'
But I keep getting the following error:
{
"error": {
"root_cause": [
{
"type": "class_cast_exception",
"reason": "java.lang.String cannot be cast to java.util.Map"
}
],
"type": "class_cast_exception",
"reason": "java.lang.String cannot be cast to java.util.Map"
},
"status": 500
}
What am I doing wrong here?
Upvotes: 1
Views: 2392
Reputation:
I think problem can be the \"false\" (String value) who no want to be cast.
curl -XPOST 'localhost:9200/my_index/_update_by_query' -d '
{
"query":{
"match":{
"latest_uuid":"d56ffe2095f511e6bcdd0acbdf0298e3"
}
},
"script" : "ctx._source.is_in_stock = false;"
}'
You can first try it. Waiting your feedback ! :)
Upvotes: 0
Reputation: 821
Found the solution.
Turns out that I had to use the following as script:
"script":{"inline":"ctx._source.is_in_stock = false"}
Upvotes: 0