From 96d859aa4e1741ab55de68e291c596ddda14deb0 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Sun, 24 Aug 2014 16:43:47 +0200 Subject: [PATCH] Removed the "parent" agg --- 404_Parent_Child.asciidoc | 2 +- 404_Parent_Child/60_Children_agg.asciidoc | 46 +++++++++ .../60_Parent_child_aggs.asciidoc | 94 ------------------- 3 files changed, 47 insertions(+), 95 deletions(-) create mode 100644 404_Parent_Child/60_Children_agg.asciidoc delete mode 100644 404_Parent_Child/60_Parent_child_aggs.asciidoc diff --git a/404_Parent_Child.asciidoc b/404_Parent_Child.asciidoc index 048fbc565..8d62318de 100644 --- a/404_Parent_Child.asciidoc +++ b/404_Parent_Child.asciidoc @@ -6,7 +6,7 @@ include::404_Parent_Child/50_Has_child.asciidoc[] include::404_Parent_Child/55_Has_parent.asciidoc[] -include::404_Parent_Child/60_Parent_child_aggs.asciidoc[] +include::404_Parent_Child/60_Children_agg.asciidoc[] include::404_Parent_Child/65_Grandparents.asciidoc[] diff --git a/404_Parent_Child/60_Children_agg.asciidoc b/404_Parent_Child/60_Children_agg.asciidoc new file mode 100644 index 000000000..006fd2ce5 --- /dev/null +++ b/404_Parent_Child/60_Children_agg.asciidoc @@ -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 +<>. 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. + diff --git a/404_Parent_Child/60_Parent_child_aggs.asciidoc b/404_Parent_Child/60_Parent_child_aggs.asciidoc deleted file mode 100644 index 8101caca6..000000000 --- a/404_Parent_Child/60_Parent_child_aggs.asciidoc +++ /dev/null @@ -1,94 +0,0 @@ -[[parent-child-aggs]] -=== Parent-child aggregations - -coming[1.4.0] - -///////////////////// - -TODO: Uncomment when docs exist on ref site - -Parent-child has a -{ref}search-aggregations-bucket-children-aggregation.html[`children` aggregation] and a -{ref}search-aggregations-bucket-parent-aggregation.html[`parent` aggregation], -as direct analogs to the `nested` and `reverse_nested` aggregations discussed -in <>. - -///////////////////// - -Parent-child has a `children` aggregation and a `parent` aggregation, -as direct analogs to the `nested` and `reverse_nested` aggregations discussed -in <>. - -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. - -The `parent` aggregation can be used to turn the previous example on its head. -This example shows how to find out in which country each hobby is most -popular: - -[source,json] -------------------------- -GET /company/employee/_search?search_type=count -{ - "aggs": { - "hobby": { - "terms": { <1> - "field": "hobby" - }, - "aggs": { - "branches": { - "parent": { <2> - "type": "branch" - }, - "aggs": { - "country": { - "terms": { <3> - "field": "country" - } - } - } - } - } - } - } -} -------------------------- -<1> The `hobby` field in the `employee` documents. -<2> The `parent` aggregation joins the child documents with - their associated parent of type `branch`. -<3> The `country` field from the `branch` parent documents. - - -