pub struct TermsAggregation { /* private fields */ }
Expand description
A multi-bucket value source based aggregation where buckets are dynamically built - one per unique value.
Implementations§
Source§impl TermsAggregation
impl TermsAggregation
Sourcepub fn size(self, size: u64) -> Self
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).
Sourcepub fn show_term_doc_count_error(self, show_term_doc_count_error: bool) -> Self
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.
Sourcepub fn order<T>(self, order: T) -> Selfwhere
T: Into<TermsOrderCollection>,
pub fn order<T>(self, order: T) -> Selfwhere
T: Into<TermsOrderCollection>,
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.
Sourcepub fn min_doc_count(self, min_doc_count: u16) -> Self
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
Sourcepub fn missing<T>(self, missing: T) -> Selfwhere
T: Serialize,
pub fn missing<T>(self, missing: T) -> Selfwhere
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.
Sourcepub fn include<T>(self, include: T) -> Selfwhere
T: Into<TermsInclude>,
pub fn include<T>(self, include: T) -> Selfwhere
T: Into<TermsInclude>,
The include
parameter can be set to include only specific terms in the response.
Sourcepub fn exclude<T>(self, exclude: T) -> Selfwhere
T: Into<TermsExclude>,
pub fn exclude<T>(self, exclude: T) -> Selfwhere
T: Into<TermsExclude>,
The exclude
parameter can be set to exclude specific terms from the response.
Sourcepub fn field<T>(self, field: T) -> Self
pub fn field<T>(self, field: T) -> Self
The field can be Keyword, Numeric, ip, boolean, or binary.
Trait Implementations§
Source§impl Clone for TermsAggregation
impl Clone for TermsAggregation
Source§fn clone(&self) -> TermsAggregation
fn clone(&self) -> TermsAggregation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more