Hello everyone, first of all i'd like to say that this is my first post here. Please forgive me in advance if im breaking any formatting / placement rules.
Im relatively new to elasticsearch and im trying to achieve something that countless google searches wouldn't suffice ( at least not to a point where i would understand )
So here's the gist of it:
{
"query": {
"bool": {
"must": [
{
"term": {
"exampleF": 1155
}
}
]
}
},
"aggregations": {
"unique": {
"terms" : {
"field": "fieldid"
}
}
}
}
With the following query im requesting documents based on them having 1155 on the 'exampleF' field. Furthermore im aggregating on top of that to have the documents uniquely seperated in buckets based on the field 'fieldid'. This provides me with a buckets array as expected.
Now i need to somehow get the length of that array and nothing seems to be cutting it.
I know that i can use cardinality instead of terms aggregation to get the unique values based on the field, but cardinality is based on approximation, and i need an exact value, also the cardinality would have to aggregate on top of 100k+ query results which wouldn't provide me with the exact result that im hoping to get.
I also know i can predefine size in the terms aggregation and then get the length of the buckets on the client side, but i'd rather not do that because the number of buckets might go well above 100k, but there could be scenarios where it is as low as 10.
One last thing, this also needs to happen within 1 call, which means composite aggregations where the size and after would be dynamically set are also of the table.
Based on all of this, if you folks could help me out or at least point me in a direction i would be really thankful.
Once again sorry for any formatting / topic placement rules i might've broken this is my first time posting.
Thanks in advance and have a wonderful day