WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Reverse Nested aggregation
editReverse Nested aggregation
editA special single bucket aggregation that enables aggregating on parent docs from nested documents.
Fluent DSL
editvar response = client.Search<ElasticSearchProject>(s => s .Aggregations(a => a .Nested("tags", n => n .Path(p => p.Tags) .Aggregations(aa => aa .Terms("tag_names", t => t .Field(p => p.Tags.Suffix("name")) .Aggregations(aaa => aaa .ReverseNested("tags_to_project", r => r .Path("project") .Aggregations(aaaa => aaaa .Terms("top_projects_per_tag", tt => tt .Field(p => p.Name) ) ) ) ) ) ) ) ) );
Object Initializer Syntax
editvar request = new SearchRequest { Aggregations = new Dictionary<string, IAggregationContainer> { { "tags", new AggregationContainer { Nested = new NestedAggregator { Path = "tags" }, Aggregations = new Dictionary<string, Nest.IAggregationContainer> { { "tag_names", new AggregationContainer { Terms = new TermsAggregator { Field = "tags.name" }, Aggregations = new Dictionary<string, Nest.IAggregationContainer> { { "tags_to_projects", new AggregationContainer { ReverseNested = new ReverseNestedAggregator { Path = "project" }, Aggregations = new Dictionary<string, Nest.IAggregationContainer> { { "top_projects_per_tag", new AggregationContainer { Terms = new TermsAggregator { Field = "name" } } } } } } } } } } } } } };
Refer to the original docs fore more information.