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

Terms Aggregation

More info about terms aggregation is in the official elasticsearch docs

A multi-bucket value source based aggregation where buckets are dynamically built - one per unique value.

Simple example

{
    "aggregations" : {
        "agg_genders" : {
            "terms" : { "field" : "gender" }
        }
    }
}

And now the query via DSL:

$termsAggregation = new TermsAggregation('genders', 'gender');

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

$queryArray = $search->toArray();