I have made an Elasticsearch query:
GET shop/products/_search
{
"_source": [
"similar_group.product_info.product_id",
"shop_id",
"similar_group.product_info.tags",
"similar_group.product_info.inventory",
"similar_group.product_info.name"
],
"query": {
"bool": {
"must": [
{
"nested": {
"path": "similar_group.product_info",
"query": {
"bool": {
"must": {
"term": {
"similar_group.product_info.product_id": 82
}
}
}
}
}
},
{
"term": {
"shop_id": 11
}
}
]
}
}
}
Running this query, I'm getting this as a response:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 7,
"successful": 7,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 9.741081,
"hits": [
{
"_index": "shop",
"_type": "products",
"_id": "m11g82",
"_score": 9.741081,
"_source": {
"shop_id": 11,
"similar_group": {
"product_info": [
{
"product_id": 82,
"name": "SpiderMan Toy",
"tags": [],
"inventory": 12
},
{
"product_id": 44,
"name": "Beyblade",
"tags": ["mattel"],
"inventory": 2
}
]
}
}
}
]
}
}
I need to update product_id - 82 with inventory as 0 and want to add tags for it.
How should I proceed to update these two fields which I've mentioned above?
Tried to look over solution over internet, found that we can use inline-scripts. Most of the examples are in "painless" language. Elasticsearch 2.4 uses "groovy" language. It would be great if anyone can help me with this.
Thanks a lot! in advance