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 children aggregation is in the official elasticsearch docs
A special single bucket aggregation that enables aggregating from buckets on parent document types to buckets on child documents.
{
"aggregations": {
"author_count": {
"children": {
"type": "answer"
},
"aggregations": {
"top_names": {
"terms": {
"field": "owner.display_name"
}
}
}
}
}
}
And now the query via DSL:
$termsAggregation = new TermsAggregation('top_names', 'owner.display_name');
$childrenAggregation = new ChildrenAggregation('author_count', 'answer');
$childrenAggregation->addAggregation($termsAggregation);
$search = new Search();
$search->addAggregation($childrenAggregation);
$queryArray = $search->toArray();
How can I help you explore Laravel packages today?