Hi,
I would like to know, if we can have custom aggregations in ElasticSearch, For EX: we have a use-case where we need a function like any_value(), it works like this:
Say I have the following documents in my index:
{
{
name: "sachin",
sport: "cricket",
score: 10
},
{
name: "sachin",
sport: "football"
score: 100
},
{
name: "dravid",
sport: "golf"
score: 100
},
{
name: "dravid",
sport: "baseball"
score: 50
}
}
and i need a aggregations query, which groups by name, gets the average of score, and pick any of the of the sport, so the response should be:
Response:
[ {"aggName": "sachin", "aggSport": "cricket", "aggScore": 55},
{"aggName": "dravid", "aggSport": "baseball", "aggScore": 75}]
I know that ES support aggregations like avg, sum, max, min etc on double, int etc, does it support implementations like any_string() (picks any string), first_string() (picks the first string hit) etc.
Is there a way we can achieve the functionality?
Thanks.