distinct - Elasticsearch, how to return unique values of two fields -
i have index 20 different fields. need able pull unique docs combination of fields "cat" , "sub" unique. in sql way: select unique cat, sub table a; can 1 field way:
{ "size": 0, "aggs" : { "unique_set" : { "terms" : { "field" : "cat" } } }}
but how add field check uniqueness across 2 fields?
thanks,
the way solve nested aggregations:
{ "size": 0, "aggs" : { "unique_set_1" : { "terms" : { "field" : "cats" }, "aggregations" : { "unique_set_2": { "terms": {"field": "sub"} } } } } }
Comments
Post a Comment