Suppose I have many documents like this:
{
"foo": "Something",
"bars":
[
{
"identifier": 1,
"content": "meh",
"quantity": 2
},
{
"identifier": 2,
"content": "bah",
"quantity": 1
}
]
}
How would I query the top 10 most present bars[].identifier considering the formula times it appear * quantity ?
EDIT: I achieved something like this
{
"size":0,
"aggs":{
"bars":{
"nested":{
"path":"bars"
},
"aggs":{
"top-terms-aggregation":{
"terms":{
"field":"bars.identifier",
"size":10
}
}
}
}
}
}
But still cannot multiply by the quantity field.