Excellent. That works like a dream.
And I appreciate you correcting my terminology. Thanks Igor!
Just to elaborate, my actual example is a little different from what I
posted but your solution works.
My example:
curl -XPUT 'http://localhost:9200/myindex/mytype/12' -d '{
"Name": "Entity 1",
"Description": "Jay Desc 1",
"Entities": [
{
"CategoryID": "1",
"CategoryName": "Office",
"EntityID": "1",
"EntityName": "UK"
},
{
"CategoryID": "1",
"CategoryName": "Office",
"EntityID": "2",
"EntityName": "South Africa"
},
{
"CategoryID": "2",
"CategoryName": "Team",
"EntityID": "3",
"EntityName": "Accounts"
},
{
"CategoryID": "2",
"CategoryName": "Team",
"EntityID": "4",
"EntityName": "Development"
}
]
}'
curl -XPOST 'http://localhost:9200/myindex/mytype/12/_update' -d
'{
"script" : "ctx._source.Entities.remove(Entities)",
"params" : {
"Entities":
{
"CategoryID": "2",
"CategoryName": "Team",
"EntityID": "4",
"EntityName": "Development"
}
}
}'
On Friday, 21 December 2012 15:54:09 UTC, jkerai wrote:
Hi, I'm very new to ES and am evaluating it for my search needs
Elasticsearch Platform — Find real-time answers at scale | Elastic
shows how to add elements to an array in an existing indexed document.
curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{
"script" : "ctx._source.tags += tag",
"params" : {
"tag" : "blue"
}
}'
The above should add a new element to the list.
Is it possible to remove elements from an array in a similar fashion?
e.g. the equivalent of
curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{
"script" : "ctx._source.tags -= tag",
"params" : {
"tag" : "blue"
}
}'
Aside from reading all the element entries and removing the one 1 want to
remove and updating the entire element using the _update endpoint.
--