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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.