pub struct Aggregation { /* private fields */ }Expand description
One aggregation.
Sub-aggregations nest with Aggregation::aggregate, which is how a
“average price per tag” is expressed: a terms on the tag with a stats
inside it.
Implementations§
Source§impl Aggregation
impl Aggregation
Sourcepub fn terms(field: impl Into<String>) -> Aggregation
pub fn terms(field: impl Into<String>) -> Aggregation
A bucket per distinct value.
Only works on a field that is not analysed — keyword, a number, a
date. On a text field the cluster answers 400 and tells you to enable
fielddata, which is almost never the right answer; adding a keyword
sub-field to the mapping is. See crate::Field::text.
Sourcepub fn stats(field: impl Into<String>) -> Aggregation
pub fn stats(field: impl Into<String>) -> Aggregation
Count, min, max, average and sum of a numeric field, in one pass.
pub fn min(field: impl Into<String>) -> Aggregation
pub fn max(field: impl Into<String>) -> Aggregation
pub fn avg(field: impl Into<String>) -> Aggregation
pub fn sum(field: impl Into<String>) -> Aggregation
Sourcepub fn cardinality(field: impl Into<String>) -> Aggregation
pub fn cardinality(field: impl Into<String>) -> Aggregation
How many distinct values — approximate, and deliberately so: an exact count would mean holding every value in memory on one node.
Sourcepub fn value_count(field: impl Into<String>) -> Aggregation
pub fn value_count(field: impl Into<String>) -> Aggregation
How many documents have the field at all.
Sourcepub fn date_histogram(
field: impl Into<String>,
interval: impl Into<String>,
) -> Aggregation
pub fn date_histogram( field: impl Into<String>, interval: impl Into<String>, ) -> Aggregation
Buckets over time: date_histogram("created_at", "day").
Sent as calendar_interval, so a month is a real month and a day
survives a daylight-saving change. fixed_interval — exact multiples of
a duration — is available through Aggregation::option.
Sourcepub fn raw(kind: impl Into<String>, body: Json) -> Aggregation
pub fn raw(kind: impl Into<String>, body: Json) -> Aggregation
An aggregation this module does not name.
Sourcepub fn size(self, size: u32) -> Aggregation
pub fn size(self, size: u32) -> Aggregation
How many buckets to return.
Applies to the bucket aggregations. The default is 10, which is the
quietest way to lose data in this API: the eleventh tag simply is not
in the answer, and nothing in the response says a number is missing
except crate::TermsResult::is_approximate.
Sourcepub fn min_doc_count(self, count: u64) -> Aggregation
pub fn min_doc_count(self, count: u64) -> Aggregation
Ignore buckets with fewer than this many documents.
Sourcepub fn missing(self, value: impl Into<Json>) -> Aggregation
pub fn missing(self, value: impl Into<Json>) -> Aggregation
Treat documents without the field as having this value, instead of leaving them out entirely.
Sourcepub fn option(self, name: impl Into<String>, value: Json) -> Aggregation
pub fn option(self, name: impl Into<String>, value: Json) -> Aggregation
Any other option the aggregation takes.
Sourcepub fn aggregate(
self,
name: impl Into<String>,
sub: impl Into<Aggregation>,
) -> Aggregation
pub fn aggregate( self, name: impl Into<String>, sub: impl Into<Aggregation>, ) -> Aggregation
Nest another aggregation inside each bucket of this one.