October 2019
Beginner
186 pages
5h 39m
English
This calculates an approximate count of distinct values using a single-value metrics aggregation. Values can be retrieved from fields in a document or from a script. Continuing our example from the previous section, let's index the sales of backpacks from the store:
POST /sales/_search?size=0{ "aggs": { "type_count": { "cardinality": { "field": "type" } } }}
The precision_control option allows the user to trade memory for accuracy by defining a count below which values are expected to be accurate. Any value above this threshold will define counts as fuzzy. Note that this threshold defaults to 3,000. To compute exact counts, users need to load values into a hash set and return the size—but this is not applicable to ...
Read now
Unlock full access