IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Parent Aggregation Usage
editParent Aggregation Usage
editA special single bucket aggregation that selects parent documents that have the specified type, as defined in a join
field.
Be sure to read the Elasticsearch documentation on Parent Aggregation.
Fluent DSL example
editObject Initializer syntax example
editnew ParentAggregation("name_of_parent_agg", typeof(CommitActivity)) { Aggregations = new AverageAggregation("average_commits", Field<Project>(f => f.NumberOfCommits)) && new MaxAggregation("max_commits", Field<Project>(f => f.NumberOfCommits)) && new MinAggregation("min_commits", Field<Project>(f => f.NumberOfCommits)) }
|
|
sub-aggregations are on the type determined from the |
Example json output.
{ "size": 0, "aggs": { "name_of_parent_agg": { "parent": { "type": "commits" }, "aggs": { "average_commits": { "avg": { "field": "numberOfCommits" } }, "max_commits": { "max": { "field": "numberOfCommits" } }, "min_commits": { "min": { "field": "numberOfCommits" } } } } } }
Handling Responses
editresponse.ShouldBeValid(); var parentAgg = response.Aggregations.Parent("name_of_parent_agg"); parentAgg.Should().NotBeNull(); parentAgg.DocCount.Should().BeGreaterThan(0); parentAgg.Min("average_commits").Should().NotBeNull(); parentAgg.Min("min_commits").Should().NotBeNull(); parentAgg.Max("max_commits").Should().NotBeNull();