pub struct HistogramAggregation {
pub field: String,
pub interval: Option<f64>,
pub offset: Option<f64>,
pub missing: Option<f64>,
pub min_doc_count: Option<u64>,
pub extended_bounds: Option<HistogramBounds>,
pub hard_bounds: Option<HistogramBounds>,
}Expand description
The histogram aggregation is a multi-bucket aggregation that can be applied on numeric values or numeric range values extracted from the documents. It dynamically builds fixed size (a.k.a. interval) buckets over the values. For example, if the documents have a field that holds a price (numeric), we can configure this aggregation to dynamically build buckets with interval 5 (in case of price it may represent $5). When the aggregation executes, the price field of every document will be evaluated and will be rounded down to its closest bucket - for example, if the price is 32 and the bucket size is 5 then the rounding will yield 30 and thus the document will “fall” into the bucket that is associated with the key 30. To make this more formal, here is the rounding function that is used:
bucket_key = Math.floor((value - offset) / interval) * interval + offsetFor range values, a document can fall into multiple buckets. The first bucket is computed from the lower bound of the range in the same way as a bucket for a single value is computed. The final bucket is computed in the same way from the upper bound of the range, and the range is counted in all buckets in between and including those two.
Note: until GraphQL Union input types are supported, either
calendarInterval or fixedInterval must be specified but not both.
Fields§
§field: StringThe field to perform the aggregation over.
interval: Option<f64>The histogram aggregation will sum the counts of each interval
computed based on the values.
offset: Option<f64>By default the bucket keys start with 0 and then continue in even spaced steps of interval, e.g. if the interval is 10, the first three buckets (assuming there is data inside them) will be [0, 10), [10, 20), [20, 30)`. The bucket boundaries can be shifted by using
the offset option.
This can be best illustrated with an example. If there are 10
documents with values ranging from 5 to 14, using interval 10 will
result in two buckets with 5 documents each. If an additional offset
5 is used, there will be only one single bucket [5, 15) containing
all the 10 documents.
missing: Option<f64>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.
min_doc_count: Option<u64>By default the response will fill gaps in the histogram with empty
buckets. To fill the gaps with a different amount, use min_doc_count.
extended_bounds: Option<HistogramBounds>With extended_bounds setting, you can “force” the histogram
aggregation to start building buckets on a specific min value and also
keep on building buckets up to a max value (even if there are no
documents anymore). Using extended_bounds only makes sense when
min_doc_count is 0 (the empty buckets will never be returned if
min_doc_count is greater than 0).
hard_bounds: Option<HistogramBounds>The hard_bounds option is a counterpart of extended_bounds and can
limit the range of buckets in the histogram. It is particularly useful
in the case of open data ranges that can result in a very large number
of buckets.
Implementations§
Source§impl HistogramAggregation
impl HistogramAggregation
Sourcepub fn builder() -> HistogramAggregationBuilder<((), (), (), (), (), (), ())>
pub fn builder() -> HistogramAggregationBuilder<((), (), (), (), (), (), ())>
Create a builder for building HistogramAggregation.
On the builder, call .field(...), .interval(...)(optional), .offset(...)(optional), .missing(...)(optional), .min_doc_count(...)(optional), .extended_bounds(...)(optional), .hard_bounds(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of HistogramAggregation.
Trait Implementations§
Source§impl Clone for HistogramAggregation
impl Clone for HistogramAggregation
Source§fn clone(&self) -> HistogramAggregation
fn clone(&self) -> HistogramAggregation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more