Struct elastiql::aggregation::types::WeightedAverageAggregation [−][src]
pub struct WeightedAverageAggregation { pub value: InnerAggregation, pub weight: InnerAggregation, pub format: Option<String>, pub value_type: Option<String>, }
Expand description
A single-value
metrics aggregation that computes the weighted average
of numeric values that are extracted from the aggregated documents. These
values can be extracted either from specific numeric fields in the
documents.
When calculating a regular average, each datapoint has an equal “weight”… it contributes equally to the final value. Weighted averages, on the other hand, weight each datapoint differently. The amount that each datapoint contributes to the final value is extracted from the document, or provided by a script.
As a formula, a weighted average is the ∑(value * weight) / ∑(weight)
A regular average can be thought of as a weighted average where every value
has an implicit weight of 1
.
Fields
value: InnerAggregation
The configuration for the field or script that provides the values
weight: InnerAggregation
The configuration for the field or script that provides the weights
format: Option<String>
The numeric response formatter
value_type: Option<String>
A hint about the values for pure scripts or unmapped fields
Implementations
Create a builder for building WeightedAverageAggregation
.
On the builder, call .value(...)
, .weight(...)
, .format(...)
(optional), .value_type(...)
(optional) to set the values of the fields.
Finally, call .build()
to create the instance of WeightedAverageAggregation
.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for WeightedAverageAggregation
impl Send for WeightedAverageAggregation
impl Sync for WeightedAverageAggregation
impl Unpin for WeightedAverageAggregation
impl UnwindSafe for WeightedAverageAggregation
Blanket Implementations
Mutably borrows from an owned value. Read more