Hi Henrik,

Indeed, there is no way to compute exact unique counts. The reason why we
don't expose such a feature is that it would be very costly. In your case,
the cardinality is not too large so the terms aggregation helped compute
the number of unique values but if the actual cardinality had been very
large (eg. 100M), it is very likely that trying to use the terms agg to do
so would have required a lot of memory (maybe triggering out-of-memory
errors on your nodes), been very slow and caused a lot of network traffic.
We will try to clarify this through documentation or a blog post soon.

Thanks for trying out this new aggregation!



On Mon, Mar 31, 2014 at 11:09 PM, Henrik Nordvik <[email protected]> wrote:

> Ah, so there is currently not easy way of getting exact unique counts out
> of elasticsearch?
>
> I found a manual way of doing it:
>
> curl -s 'http://localhost:9200/twitter-2014.03.26/_search' -d '{
> "facets": { "a": {  "terms": { "field": "screen_name", "size":
> 200000},"facet_filter": {"query": {"term": {"lang": "en"}}}}},"size": 0}' |
> ./jq '.facets.a.terms | length'
> 145474 (vs 145541)
> curl -s 'http://localhost:9200/twitter-2014.03.26/_search' -d '{
> "facets": { "a": {  "terms": { "field": "screen_name", "size":
> 200000},"facet_filter": {"query": {"term": {"lang": "ja"}}}}},"size": 0}' |
> ./jq '.facets.a.terms | length'
> 50949 (vs 50824)
>
> So the count is quite close! Thank you.
>
>
>
> On Friday, March 28, 2014 10:32:55 PM UTC+1, Binh Ly wrote:
>>
>> value_count is the total number of values extracted per bucket. This
>> example might help:
>>
>> https://gist.github.com/bly2k/9843335
>>
>  --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/8669e9f0-eece-4b77-8e99-fec483359e2f%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/8669e9f0-eece-4b77-8e99-fec483359e2f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adrien Grand

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7Qxe0SJSfFreK%3DfpqSBfziLzTVoGgi-T73J1YDx6ApTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to