How to Combine Script Sort and Nested Search and Sort
I know how to search a nested object and also how to sort by script sort.
How could they work together?....
Say I have doc as following
{
"id": 1,
"tag": [ { "desc": "a", "weight": 0.8 }, { "desc": "b", "weight": 0.6 }, { "desc": "c", "weight": 0.4 } ]
}
{
"id": 2,
"tag": [ { "desc": "a", "weight": 0.4 }, { "desc": "c", "weight": 0.7 } ]
}
{
"id": 3,
"tag": [ { "desc": "a", "weight": 2.0 } ]
}
I want to search for tag [a or c] and sort by sum of their weight
So I want
doc 3 > doc 1 > doc 2,
with weight is 2.0 > 0.8+0.4 > 0.4+0.7
How can I achieve that?