I use elasticsearch to search a database with lots of duplicates. I use field collapse and it works, however it returns the number of hits (including duplicates), not the number of buckets.
"aggs": { "uniques": { "terms": { "field": "guid" }, "aggs": { "jobs": { "top_hits": { "_source": "title", "size": 1 }} } } }
I can count the buckets by running another query using capacity (but it only returns the bill, not the documents):
{ "aggs" : { "uniques" : { "cardinality" : { "field" : "guid" } } } }
Is there a way to return both queries (buckets + total number of buckets) in one search?
thanks
elasticsearch
peixotorms
source share