I have an index from which I would like to search for a text & get top 100 results and perform aggregation to retrieve the uniqueIds from those 100 results & sort them by their max_value/sum_value. At present I am using the query below which performs aggregations on around 100K results. But I want this aggregation to be limited to my first 100 results
{
"size": 0,
"query": {
"multi_match": {
"query": "game of thrones",
"fields": ["Textfield", "Textfield.shingles^3"]
}
},
"aggs" : {
"Bucketized_Results" : {
"terms" : {
"field" : "uniqueId",
"order": {"max_score": "desc"}
},
"aggs": {
"max_score": {
"max": {
"script": "_score"
}
}
}
}
}
}