- .NET Clients: other versions:
- Introduction
- Building
- Breaking Changes
- Elasticsearch.Net
- NEST
- Core
- Indices
- Cluster
- Search
- Aggregations
- Handling Aggregations
- Avg aggregation
- Cardinality aggregation
- Date Histogram aggregation
- Date Range aggregation
- Extended Stats Aggregation
- Filter aggregation
- Geo Distance aggregation
- Geohash Grid aggregation
- Global aggregation
- Histogram aggregation
- IPv4 Range aggregation
- Max aggregation
- Min aggregation
- Missing aggregation
- Percentiles aggregation
- Percentile Ranks aggregation
- Range aggregation
- Nested aggregation
- Reverse Nested aggregation
- Significant Terms aggregation
- Stats aggregation
- Sum aggregation
- Terms aggregation
- Top Hits aggregation
- Value Count aggregation
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
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Reverse 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.
On this page
Was this helpful?
Thank you for your feedback.