Min Aggregation
The Min
aggregation is a single-value metrics aggregation that keeps track and returns the minimum value among the numeric values extracted from the aggregated documents.
In order to use the Min
aggregation import the following:
import zio.elasticsearch.aggregation.MinAggregation
import zio.elasticsearch.ElasticAggregation.minAggregation
You can create a Min
aggregation using the minAggregation
method this way:
val aggregation: MinAggregation = minAggregation(name = "minAggregation", field = "intField")
You can create a type-safe Min
aggregation using the minAggregation
method this way:
// Document.intField must be number value, because of Min aggregation
val aggregation: MinAggregation = minAggregation(name = "minAggregation", field = Document.intField)
If you want to change the missing
parameter, you can use missing
method:
val aggregationWithMissing: MinAggregation = minAggregation(name = "minAggregation", field = Document.intField).missing(10.0)
If you want to add aggregation (on the same level), you can use withAgg
method:
val multipleAggregations: MultipleAggregations = minAggregation(name = "minAggregation1", field = Document.intField).withAgg(minAggregation(name = "minAggregation2", field = Document.doubleField))
You can find more information about Min
aggregation here.