Struct elasticsearch_dsl::search::aggregations::bucket::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.
Implementations
sourceimpl 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) -> Self where
T: Into<TermsOrderCollection>,
pub fn order<T>(self, order: T) -> Self where
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) -> Self where
T: Serialize,
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.
sourcepub fn aggregate<N, A>(self, aggregation_name: N, aggregation: A) -> Self where
N: Into<AggregationName>,
A: Into<Aggregation>,
pub fn aggregate<N, A>(self, aggregation_name: N, aggregation: A) -> Self where
N: Into<AggregationName>,
A: Into<Aggregation>,
Pushes aggregation
Trait Implementations
sourceimpl Clone for TermsAggregation
impl Clone for TermsAggregation
sourcefn clone(&self) -> TermsAggregation
fn clone(&self) -> TermsAggregation
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TermsAggregation
impl Debug for TermsAggregation
sourceimpl From<TermsAggregation> for Aggregation
impl From<TermsAggregation> for Aggregation
sourcefn from(q: TermsAggregation) -> Self
fn from(q: TermsAggregation) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<TermsAggregation> for TermsAggregation
impl PartialEq<TermsAggregation> for TermsAggregation
sourcefn eq(&self, other: &TermsAggregation) -> bool
fn eq(&self, other: &TermsAggregation) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TermsAggregation) -> bool
fn ne(&self, other: &TermsAggregation) -> bool
This method tests for !=
.
sourceimpl Serialize for TermsAggregation
impl Serialize for TermsAggregation
impl StructuralPartialEq for TermsAggregation
Auto Trait Implementations
impl RefUnwindSafe for TermsAggregation
impl Send for TermsAggregation
impl Sync for TermsAggregation
impl Unpin for TermsAggregation
impl UnwindSafe for TermsAggregation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more