Hi, I am using ES to build term aggregations and was trying to see if there is some way of doing a "get distinct" based on a field as the first step of the aggregation. Here is what I am trying to do :
Records
{"my_id":"a", "someField":"X"}
{"my_id":"a", "someField":"X"}
{"my_id":"b", "someField":"Y"}
{"my_id":"c", "someField":"Z"}
{"my_id":"d", "someField":"Z"}
And then I want to do a term aggregation by "someField" where all records having the same "my_id" are considered only once, thus resulting in something like :
{ "someField": { "buckets": [{ "key": "X", "count": 1 }, { "key": "Y", "count": 1 }, { "key": "Z", "count": 2 }] } }
Let me underline that the bucket for X has count 1
Any way/ideas on how to achieve this ?
Thanks!