Elasticsearch 1.1+ has the Cardinality Aggregation which will give you a unique count
Note that it is actually an approximation and accuracy may diminish with high-cardinality datasets, but it's generally pretty accurate in my testing.
You can also tune the accuracy with the precision_threshold
parameter. The trade-off, or course, is memory usage.
This graph from the docs shows how a higher precision_threshold
leads to much more accurate results.