Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Value Count Aggregation

More info about value count aggregation is in the official elasticsearch docs

A single-value metrics aggregation that counts the number of values that are extracted from the aggregated documents.

Simple example

{
    "aggregations" : {
        "grades_count" : { "value_count" : { "field" : "grade" } }
    }
}

And now the query via DSL:

$valueCountAggregation = new ValueCountAggregation('grades_count', 'grade');

$search = new Search();
$search->addAggregation($valueCountAggregation);

$queryArray = $search->toArray();