Struct TermsAggregation

Source
pub struct TermsAggregation { /* private fields */ }
Expand description

A multi-bucket value source based aggregation where buckets are dynamically built - one per unique value.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

Implementations§

Source§

impl TermsAggregation

Source

pub fn size(self, size: u64) -> Self

The size parameter can be set to define how many term buckets should be returned out of the overall terms list.

By default, the node coordinating the search process will request each shard to provide its own top size term buckets and once all shards respond, it will reduce the results to the final list that will then be returned to the client.

This means that if the number of unique terms is greater than size, the returned list is slightly off and not accurate (it could be that the term counts are slightly off and it could even be that a term that should have been in the top size buckets was not returned).

Source

pub fn show_term_doc_count_error(self, show_term_doc_count_error: bool) -> Self

Shows an error value for each term returned by the aggregation which represents the worst case error in the document count and can be useful when deciding on a value for the shard_size parameter. This is calculated by summing the document counts for the last term returned by all shards which did not return the term.

Source

pub fn order<T>(self, order: T) -> Self

The order of the buckets can be customized by setting the order parameter. By default, the buckets are ordered by their doc_count descending. Order field allows changing this behavior.

Sorting by ascending _count or by sub aggregation is discouraged as it increases the error on document counts. It is fine when a single shard is queried, or when the field that is being aggregated was used as a routing key at index time: in these cases results will be accurate since shards have disjoint values. However otherwise, errors are unbounded. One particular case that could still be useful is sorting by min or max aggregation: counts will not be accurate but at least the top buckets will be correctly picked.

Source

pub fn min_doc_count(self, min_doc_count: u16) -> Self

Only returns terms that match more than a configured number of hits using the min_doc_count

Default value is 1

Source

pub fn missing<T>(self, missing: T) -> Self
where T: Serialize,

The missing parameter defines how documents that are missing a value should be treated. By default they will be ignored but it is also possible to treat them as if they had a value.

Source

pub fn include<T>(self, include: T) -> Self
where T: Into<TermsInclude>,

The include parameter can be set to include only specific terms in the response.

Source

pub fn exclude<T>(self, exclude: T) -> Self
where T: Into<TermsExclude>,

The exclude parameter can be set to exclude specific terms from the response.

Source

pub fn script(self, script: Script) -> Self

Sets the script for the aggregation.

Source

pub fn field<T>(self, field: T) -> Self
where T: Into<String>,

The field can be Keyword, Numeric, ip, boolean, or binary.

Source

pub fn aggregate<N, A>(self, aggregation_name: N, aggregation: A) -> Self

Pushes aggregation

Trait Implementations§

Source§

impl Clone for TermsAggregation

Source§

fn clone(&self) -> TermsAggregation

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TermsAggregation

Source§

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

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

impl From<TermsAggregation> for Aggregation

Source§

fn from(q: TermsAggregation) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for TermsAggregation

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TermsAggregation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TermsAggregation

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.