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 avg aggregation is in the official elasticsearch docs
A single-value metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents.
{
"aggregations": {
"avg_grade": {
"avg": {
"field": "grade"
}
}
}
}
And now the query via DSL:
$avgAggregation = new AvgAggregation('avg_grade');
$avgAggregation->setField('grade');
$search = new Search();
$search->addAggregation($avgAggregation);
$queryArray = $search->toArray();
How can I help you explore Laravel packages today?