Value count Aggregation
The Value count
aggregation is a single-value metrics aggregation that calculates the number of values that an aggregation is based on.
In order to use the Value count
aggregation import the following:
import zio.elasticsearch.aggregation.ValueCountAggregation
import zio.elasticsearch.ElasticAggregation.valueCountAggregation
You can create a Value count
aggregation using the valueCountAggregation
method this way:
val aggregation: ValueCountAggregation = valueCountAggregation(name = "valueCountAggregation", field = "stringField")
You can create a type-safe Value count
aggregation using the valueCountAggregation
method this way:
val aggregation: ValueCountAggregation = valueCountAggregation(name = "valueCountAggregation", field = Document.stringField)
If you want to add aggregation (on the same level), you can use withAgg
method:
val multipleAggregations: MultipleAggregations = valueCountAggregation(name = "valueCountAggregation1", field = Document.stringField).withAgg(valueCountAggregation(name = "valueCountAggregation2", field = Document.intField))
You can find more information about Value count
aggregation here.