Muninn.Aggregation (Muninn v0.5.5)
View SourceBuilder for constructing aggregation requests.
Aggregations compute analytics over search results — counting documents per category, computing average prices, building histograms, etc.
Examples
alias Muninn.Aggregation
alias Muninn.Aggregation.{Bucket, Metric}
# Simple terms aggregation
aggs = Aggregation.new()
|> Aggregation.add("categories", Bucket.terms("category", size: 10))
{:ok, results} = Muninn.Searcher.aggregate(searcher, "*", ["title"], aggs)
# Nested: stats per category
aggs = Aggregation.new()
|> Aggregation.add("categories",
Bucket.terms("category", size: 10)
|> Aggregation.sub("price_stats", Metric.stats("price"))
)
Summary
Functions
Adds a named aggregation to the request.
Creates a new empty aggregation request.
Adds a sub-aggregation to a bucket aggregation.
Types
@type t() :: map()
Functions
Adds a named aggregation to the request.
@spec new() :: t()
Creates a new empty aggregation request.
Adds a sub-aggregation to a bucket aggregation.