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 nested aggregation is in the official elasticsearch docs
A special single bucket aggregation that enables aggregating nested documents.
{
"aggregations" : {
"resellers" : {
"nested" : {
"path" : "resellers"
},
"aggregations" : {
"min_price" : { "min" : { "field" : "resellers.price" } }
}
}
}
}
And now the query via DSL:
$minAggregation = new MinAggregation('min_price', 'resellers.price');
$nestedAggregation = new NestedAggregation('resellers', 'resellers');
$nestedAggregation->addAggregation($minAggregation);
$search = new Search();
$search->addAggregation($nestedAggregation);
$queryArray = $search->toArray();
How can I help you explore Laravel packages today?