I have objects of which some are grouped by a 'masterID'. I need an aggregation/query that shows me as result the object with the highest 'relevance' per object group by 'masterID'.
With aggregation of term 'masterID' I can get buckets for each 'masterID'. But how do I get the highest 'relevance' object within each bucket?
The queries so far are:
curl -XGET 'http://localhost:9200/pwo/_search?search_type=count&size=0&pretty=true' -d '{
"aggregations": {
"masterIDs": {
"terms": {
"field": "masterID",
"size": 0
}
}
}
}
'
and
curl -XGET 'http://localhost:9200/pwo/_search?size=0&pretty=true' -d '{
"aggregations": {
"relevance": {
"max": {
"field": "relevance"
}
}
}
}
'
Is there a way to solve this with a single query?
relevanceaggregation block in themasterIDsblock