Skip to main content

Aggregation

Struct Aggregation 

Source
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

Source

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.

Source

pub fn stats(field: impl Into<String>) -> Aggregation

Count, min, max, average and sum of a numeric field, in one pass.

Source

pub fn min(field: impl Into<String>) -> Aggregation

Source

pub fn max(field: impl Into<String>) -> Aggregation

Source

pub fn avg(field: impl Into<String>) -> Aggregation

Source

pub fn sum(field: impl Into<String>) -> Aggregation

Source

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.

Source

pub fn value_count(field: impl Into<String>) -> Aggregation

How many documents have the field at all.

Source

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.

Source

pub fn raw(kind: impl Into<String>, body: Json) -> Aggregation

An aggregation this module does not name.

Source

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.

Source

pub fn min_doc_count(self, count: u64) -> Aggregation

Ignore buckets with fewer than this many documents.

Source

pub fn missing(self, value: impl Into<Json>) -> Aggregation

Treat documents without the field as having this value, instead of leaving them out entirely.

Source

pub fn option(self, name: impl Into<String>, value: Json) -> Aggregation

Any other option the aggregation takes.

Source

pub fn aggregate( self, name: impl Into<String>, sub: impl Into<Aggregation>, ) -> Aggregation

Nest another aggregation inside each bucket of this one.

Source

pub fn body(&self) -> Json

The JSON this aggregation sends.

Trait Implementations§

Source§

impl Clone for Aggregation

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Aggregation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Aggregation

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Aggregation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.