Skip to content
Snippets Groups Projects
Commit 9f4b188b authored by Aivaras Gotovskis's avatar Aivaras Gotovskis
Browse files

Add children aggregation doc.

parent 08b8fff7
No related branches found
No related tags found
No related merge requests found
# Children Aggregation
> More info about children aggregation is in the [official elasticsearch docs][1]
A special single bucket aggregation that enables aggregating from buckets on parent
document types to buckets on child documents.
## Simple example
```JSON
{
"aggregations": {
"agg_author_count": {
"children": {
"type": "answer"
},
"aggregations": {
"agg_top_names": {
"terms": {
"field": "owner.display_name"
}
}
}
}
}
}
```
And now the query via DSL:
```php
$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();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment