Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Aggregations Deep Dive: Bucket aggregations, Metric aggregations, and Precision Threshold in `cardinality`.
senior LevelelasticsearchAdvanced Internals
In Simple Words:
- Bucket Aggregations: Group documents into sets/buckets (e.g.
terms,date_histogram,range). - Metric Aggregations: Compute mathematical metrics over document sets (e.g.
avg,sum,min,percentiles). - Cardinality Aggregation (HyperLogLog++): Counting unique visitors over billions of records. Instead of keeping a set of billions of strings in memory, Elasticsearch uses the probabilistic HyperLogLog++ algorithm:
- Controlled by
precision_threshold(default 3,000). Guarantees < 5% error with negligible memory usage.
- Controlled by