11using System ;
2- using Nest ;
3- using Tests . Framework ;
4- using Tests . Framework . MockData ;
5- using static Nest . Infer ;
62using System . Collections . Generic ;
73using System . Linq ;
4+ using FluentAssertions ;
5+ using Nest ;
86using Tests . Aggregations . Bucket . Children ;
7+ using Tests . Framework ;
98using Tests . Framework . Integration ;
10- using FluentAssertions ;
9+ using Tests . Framework . MockData ;
10+ using static Nest . Infer ;
1111
1212namespace Tests . Aggregations
1313{
@@ -52,6 +52,13 @@ public class Usage : UsageTestBase<ISearchRequest, SearchDescriptor<Project>, Se
5252 {
5353 field = "confidenceFactor"
5454 }
55+ } ,
56+ min_per_child = new
57+ {
58+ min = new
59+ {
60+ field = "confidenceFactor"
61+ }
5562 }
5663 }
5764 }
@@ -68,6 +75,7 @@ public class Usage : UsageTestBase<ISearchRequest, SearchDescriptor<Project>, Se
6875 . Aggregations ( childAggs => childAggs
6976 . Average ( "average_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
7077 . Max ( "max_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
78+ . Min ( "min_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
7179 )
7280 )
7381 ) ;
@@ -85,6 +93,7 @@ public class Usage : UsageTestBase<ISearchRequest, SearchDescriptor<Project>, Se
8593 Aggregations =
8694 new AverageAggregation ( "average_per_child" , "confidenceFactor" )
8795 && new MaxAggregation ( "max_per_child" , "confidenceFactor" )
96+ && new MinAggregation ( "min_per_child" , "confidenceFactor" )
8897 }
8998 } ;
9099 }
@@ -106,6 +115,7 @@ public class AggregationDslUsage : Usage
106115 Aggregations =
107116 new AverageAggregation ( "average_per_child" , Field < CommitActivity > ( p => p . ConfidenceFactor ) )
108117 && new MaxAggregation ( "max_per_child" , Field < CommitActivity > ( p => p . ConfidenceFactor ) )
118+ && new MinAggregation ( "min_per_child" , Field < CommitActivity > ( p => p . ConfidenceFactor ) )
109119 }
110120 } ;
111121 }
@@ -125,7 +135,8 @@ protected override Func<SearchDescriptor<Project>, ISearchRequest> Fluent
125135 var aggregations = new List < Func < AggregationContainerDescriptor < CommitActivity > , IAggregationContainer > > //<1> a list of aggregation functions to apply
126136 {
127137 a => a . Average ( "average_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) ) ,
128- a => a . Max ( "max_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
138+ a => a . Max ( "max_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) ) ,
139+ a => a . Min ( "min_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
129140 } ;
130141
131142 return s => s
@@ -140,6 +151,30 @@ protected override Func<SearchDescriptor<Project>, ISearchRequest> Fluent
140151 }
141152 }
142153
154+ public class AndMultipleDescriptorsUsage : Usage
155+ {
156+ /**
157+ * Combining multipe `AggregationDescriptor`'s is also possible using the bitwise `&` operator
158+ */
159+ protected override Func < SearchDescriptor < Project > , ISearchRequest > Fluent
160+ {
161+ get
162+ {
163+ var aggregations = new AggregationContainerDescriptor < CommitActivity > ( )
164+ . Average ( "average_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
165+ . Max ( "max_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
166+ && new AggregationContainerDescriptor < CommitActivity > ( )
167+ . Min ( "min_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) ) ;
168+
169+ return s => s
170+ . Aggregations ( aggs => aggs
171+ . Children < CommitActivity > ( "name_of_child_agg" , child => child
172+ . Aggregations ( childAggs => aggregations )
173+ )
174+ ) ;
175+ }
176+ }
177+ }
143178 /**[[aggs-vs-aggregations]]
144179 *=== Aggs vs. Aggregations
145180 *
@@ -161,6 +196,7 @@ public AggsUsage(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }
161196 . Aggregations ( childAggs => childAggs
162197 . Average ( "average_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
163198 . Max ( "max_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
199+ . Min ( "min_per_child" , avg => avg . Field ( p => p . ConfidenceFactor ) )
164200 )
165201 )
166202 ) ;
0 commit comments