How to return the count of unique documents by using elasticsearch aggregation

Hi,

Is there a way to return the count of the unique documents by using
aggregation?

My use case is pretty simple:

In my data model I have an array of locations :
{
...,
"locations" : [
{
"city" : "new york",
"state" : "ny"
},
{
"city" : "woodbury",
"state" : "ny"
}
]
}

The "locations" field is of nested object, and it has "city" and "state"
field.

Let's say I only have this one entry in my elasticsearch server and I ran
terms aggregation on the state field, however the doc_count in the "ny"
bucket is 2 rather than 1.

Basically I want elasticsearch to return the count of distinct results (or
return the distinct results).

Is there anyway to do it?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/06744c33-e265-4cc4-8c59-8fca953ed7d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.