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 stats aggregation is in the official elasticsearch docs
A multi-value metrics aggregation that computes stats over numeric values extracted from the aggregated documents.
{
"aggregations" : {
"grades_stats" : { "stats" : { "field" : "grade" } }
}
}
And now the query via DSL:
$statsAggregation = new StatsAggregation('grades_stats', 'grade');
$search = new Search();
$search->addAggregation($statsAggregation);
$queryArray = $search->toArray();
How can I help you explore Laravel packages today?