ongr/elasticsearch-dsl
Object-oriented Elasticsearch query builder for PHP. Build searches, filters, aggregations and more with a DSL, then export to arrays for elasticsearch-php or ONGR ElasticsearchBundle. Supports Elasticsearch 5/6/7 via versioned releases.
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.
{
"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();
How can I help you explore Laravel packages today?