forked from elasticsearch-cn/elasticsearch-definitive-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b3452d
commit 96d859a
Showing
3 changed files
with
47 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[[children-agg]] | ||
=== Children aggregation | ||
|
||
coming[1.4.0] | ||
|
||
Parent-child supports a | ||
{ref}search-aggregations-bucket-children-aggregation.html[`children` | ||
aggregation] as a direct analog to the `nested` aggregation discussed in | ||
<<nested-aggregation>>. A parent aggregation (the equivalent of | ||
`reverse_nested`) is not supported. | ||
|
||
This example demonstrates how we could determine the favourite hobbies of our | ||
employees by country: | ||
|
||
[source,json] | ||
------------------------- | ||
GET /company/branch/_search?search_type=count | ||
{ | ||
"aggs": { | ||
"country": { | ||
"terms": { <1> | ||
"field": "country" | ||
}, | ||
"aggs": { | ||
"employees": { | ||
"children": { <2> | ||
"type": "employee" | ||
}, | ||
"aggs": { | ||
"hobby": { | ||
"terms": { <3> | ||
"field": "hobby" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
------------------------- | ||
<1> The `country` field in the `branch` documents. | ||
<2> The `children` aggregation joins the parent documents with | ||
their associated children of type `employee`. | ||
<3> The `hobby` field from the `employee` child documents. | ||
|
This file was deleted.
Oops, something went wrong.