5
5
6
6
namespace Nest
7
7
{
8
- [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter ) ) ]
8
+ [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter < string , IAggregationContainer > ) ) ]
9
9
public class AggregationDictionary : IsADictionaryBase < string , IAggregationContainer >
10
10
{
11
- public AggregationDictionary ( ) : base ( ) { }
11
+ public AggregationDictionary ( ) { }
12
12
public AggregationDictionary ( IDictionary < string , IAggregationContainer > container ) : base ( container ) { }
13
13
public AggregationDictionary ( Dictionary < string , AggregationContainer > container )
14
14
: base ( container . ToDictionary ( kv => kv . Key , kv => ( IAggregationContainer ) kv . Value ) )
@@ -50,7 +50,7 @@ public static implicit operator AggregationDictionary(AggregationBase aggregator
50
50
public interface IAggregationContainer
51
51
{
52
52
[ JsonProperty ( "meta" ) ]
53
- [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter ) ) ]
53
+ [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter < string , object > ) ) ]
54
54
IDictionary < string , object > Meta { get ; set ; }
55
55
56
56
[ JsonProperty ( "avg" ) ]
@@ -153,17 +153,17 @@ public interface IAggregationContainer
153
153
IMinBucketAggregation MinBucket { get ; set ; }
154
154
155
155
[ JsonProperty ( "sum_bucket" ) ]
156
- ISumBucketAggregation SumBucket { get ; set ; }
157
-
158
- [ JsonProperty ( "stats_bucket" ) ]
159
- IStatsBucketAggregation StatsBucket { get ; set ; }
160
-
161
- [ JsonProperty ( "extended_stats_bucket" ) ]
162
- IExtendedStatsBucketAggregation ExtendedStatsBucket { get ; set ; }
163
-
164
- [ JsonProperty ( "percentiles_bucket" ) ]
165
- IPercentilesBucketAggregation PercentilesBucket { get ; set ; }
166
-
156
+ ISumBucketAggregation SumBucket { get ; set ; }
157
+
158
+ [ JsonProperty ( "stats_bucket" ) ]
159
+ IStatsBucketAggregation StatsBucket { get ; set ; }
160
+
161
+ [ JsonProperty ( "extended_stats_bucket" ) ]
162
+ IExtendedStatsBucketAggregation ExtendedStatsBucket { get ; set ; }
163
+
164
+ [ JsonProperty ( "percentiles_bucket" ) ]
165
+ IPercentilesBucketAggregation PercentilesBucket { get ; set ; }
166
+
167
167
[ JsonProperty ( "moving_avg" ) ]
168
168
IMovingAverageAggregation MovingAverage { get ; set ; }
169
169
@@ -180,8 +180,8 @@ public interface IAggregationContainer
180
180
IBucketSelectorAggregation BucketSelector { get ; set ; }
181
181
182
182
[ JsonProperty ( "sampler" ) ]
183
- ISamplerAggregation Sampler { get ; set ; }
184
-
183
+ ISamplerAggregation Sampler { get ; set ; }
184
+
185
185
[ JsonProperty ( "geo_centroid" ) ]
186
186
IGeoCentroidAggregation GeoCentroid { get ; set ; }
187
187
@@ -256,14 +256,14 @@ public class AggregationContainer : IAggregationContainer
256
256
257
257
public IMinBucketAggregation MinBucket { get ; set ; }
258
258
259
- public ISumBucketAggregation SumBucket { get ; set ; }
260
-
261
- public IStatsBucketAggregation StatsBucket { get ; set ; }
262
-
263
- public IExtendedStatsBucketAggregation ExtendedStatsBucket { get ; set ; }
264
-
265
- public IPercentilesBucketAggregation PercentilesBucket { get ; set ; }
266
-
259
+ public ISumBucketAggregation SumBucket { get ; set ; }
260
+
261
+ public IStatsBucketAggregation StatsBucket { get ; set ; }
262
+
263
+ public IExtendedStatsBucketAggregation ExtendedStatsBucket { get ; set ; }
264
+
265
+ public IPercentilesBucketAggregation PercentilesBucket { get ; set ; }
266
+
267
267
public IMovingAverageAggregation MovingAverage { get ; set ; }
268
268
269
269
public ICumulativeSumAggregation CumulativeSum { get ; set ; }
@@ -274,8 +274,8 @@ public class AggregationContainer : IAggregationContainer
274
274
275
275
public IBucketSelectorAggregation BucketSelector { get ; set ; }
276
276
277
- public ISamplerAggregation Sampler { get ; set ; }
278
-
277
+ public ISamplerAggregation Sampler { get ; set ; }
278
+
279
279
public IGeoCentroidAggregation GeoCentroid { get ; set ; }
280
280
281
281
public IMatrixStatsAggregation MatrixStats { get ; set ; }
@@ -373,14 +373,14 @@ public class AggregationContainerDescriptor<T> : DescriptorBase<AggregationConta
373
373
374
374
IMinBucketAggregation IAggregationContainer . MinBucket { get ; set ; }
375
375
376
- ISumBucketAggregation IAggregationContainer . SumBucket { get ; set ; }
377
-
378
- IStatsBucketAggregation IAggregationContainer . StatsBucket { get ; set ; }
379
-
380
- IExtendedStatsBucketAggregation IAggregationContainer . ExtendedStatsBucket { get ; set ; }
381
-
382
- IPercentilesBucketAggregation IAggregationContainer . PercentilesBucket { get ; set ; }
383
-
376
+ ISumBucketAggregation IAggregationContainer . SumBucket { get ; set ; }
377
+
378
+ IStatsBucketAggregation IAggregationContainer . StatsBucket { get ; set ; }
379
+
380
+ IExtendedStatsBucketAggregation IAggregationContainer . ExtendedStatsBucket { get ; set ; }
381
+
382
+ IPercentilesBucketAggregation IAggregationContainer . PercentilesBucket { get ; set ; }
383
+
384
384
IMovingAverageAggregation IAggregationContainer . MovingAverage { get ; set ; }
385
385
386
386
ICumulativeSumAggregation IAggregationContainer . CumulativeSum { get ; set ; }
@@ -391,7 +391,7 @@ public class AggregationContainerDescriptor<T> : DescriptorBase<AggregationConta
391
391
392
392
IBucketSelectorAggregation IAggregationContainer . BucketSelector { get ; set ; }
393
393
394
- ISamplerAggregation IAggregationContainer . Sampler { get ; set ; }
394
+ ISamplerAggregation IAggregationContainer . Sampler { get ; set ; }
395
395
396
396
IGeoCentroidAggregation IAggregationContainer . GeoCentroid { get ; set ; }
397
397
@@ -531,20 +531,20 @@ public AggregationContainerDescriptor<T> MinBucket(string name,
531
531
532
532
public AggregationContainerDescriptor < T > SumBucket ( string name ,
533
533
Func < SumBucketAggregationDescriptor , ISumBucketAggregation > selector ) =>
534
- _SetInnerAggregation ( name , selector , ( a , d ) => a . SumBucket = d ) ;
535
-
536
- public AggregationContainerDescriptor < T > StatsBucket ( string name ,
537
- Func < StatsBucketAggregationDescriptor , IStatsBucketAggregation > selector ) =>
538
- _SetInnerAggregation ( name , selector , ( a , d ) => a . StatsBucket = d ) ;
539
-
540
- public AggregationContainerDescriptor < T > ExtendedStatsBucket ( string name ,
541
- Func < ExtendedStatsBucketAggregationDescriptor , IExtendedStatsBucketAggregation > selector ) =>
542
- _SetInnerAggregation ( name , selector , ( a , d ) => a . ExtendedStatsBucket = d ) ;
543
-
544
- public AggregationContainerDescriptor < T > PercentilesBucket ( string name ,
545
- Func < PercentilesBucketAggregationDescriptor , IPercentilesBucketAggregation > selector ) =>
546
- _SetInnerAggregation ( name , selector , ( a , d ) => a . PercentilesBucket = d ) ;
547
-
534
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . SumBucket = d ) ;
535
+
536
+ public AggregationContainerDescriptor < T > StatsBucket ( string name ,
537
+ Func < StatsBucketAggregationDescriptor , IStatsBucketAggregation > selector ) =>
538
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . StatsBucket = d ) ;
539
+
540
+ public AggregationContainerDescriptor < T > ExtendedStatsBucket ( string name ,
541
+ Func < ExtendedStatsBucketAggregationDescriptor , IExtendedStatsBucketAggregation > selector ) =>
542
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . ExtendedStatsBucket = d ) ;
543
+
544
+ public AggregationContainerDescriptor < T > PercentilesBucket ( string name ,
545
+ Func < PercentilesBucketAggregationDescriptor , IPercentilesBucketAggregation > selector ) =>
546
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . PercentilesBucket = d ) ;
547
+
548
548
public AggregationContainerDescriptor < T > MovingAverage ( string name ,
549
549
Func < MovingAverageAggregationDescriptor , IMovingAverageAggregation > selector ) =>
550
550
_SetInnerAggregation ( name , selector , ( a , d ) => a . MovingAverage = d ) ;
@@ -567,16 +567,16 @@ public AggregationContainerDescriptor<T> BucketSelector(string name,
567
567
568
568
public AggregationContainerDescriptor < T > Sampler ( string name ,
569
569
Func < SamplerAggregationDescriptor < T > , ISamplerAggregation > selector ) =>
570
- _SetInnerAggregation ( name , selector , ( a , d ) => a . Sampler = d ) ;
571
-
572
- public AggregationContainerDescriptor < T > GeoCentroid ( string name ,
573
- Func < GeoCentroidAggregationDescriptor < T > , IGeoCentroidAggregation > selector ) =>
574
- _SetInnerAggregation ( name , selector , ( a , d ) => a . GeoCentroid = d ) ;
575
-
576
- public AggregationContainerDescriptor < T > MatrixStats ( string name ,
577
- Func < MatrixStatsAggregationDescriptor < T > , IMatrixStatsAggregation > selector ) =>
578
- _SetInnerAggregation ( name , selector , ( a , d ) => a . MatrixStats = d ) ;
579
-
570
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . Sampler = d ) ;
571
+
572
+ public AggregationContainerDescriptor < T > GeoCentroid ( string name ,
573
+ Func < GeoCentroidAggregationDescriptor < T > , IGeoCentroidAggregation > selector ) =>
574
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . GeoCentroid = d ) ;
575
+
576
+ public AggregationContainerDescriptor < T > MatrixStats ( string name ,
577
+ Func < MatrixStatsAggregationDescriptor < T > , IMatrixStatsAggregation > selector ) =>
578
+ _SetInnerAggregation ( name , selector , ( a , d ) => a . MatrixStats = d ) ;
579
+
580
580
/// <summary>
581
581
/// Fluent methods do not assign to properties on `this` directly but on IAggregationContainers inside `this.Aggregations[string, IContainer]
582
582
/// </summary>
@@ -588,27 +588,27 @@ Func<TAggregator, TAggregatorInterface> selector
588
588
where TAggregator : IAggregation , TAggregatorInterface , new ( )
589
589
where TAggregatorInterface : IAggregation
590
590
{
591
- var aggregator = selector ( new TAggregator ( ) ) ;
592
-
593
- //create new isolated container for new aggregator and assign to the right property
591
+ var aggregator = selector ( new TAggregator ( ) ) ;
592
+
593
+ //create new isolated container for new aggregator and assign to the right property
594
594
var container = new AggregationContainer ( ) { Meta = aggregator . Meta } ;
595
595
596
- assignToProperty ( container , aggregator ) ;
597
-
598
- //create aggregations dictionary on `this` if it does not exist already
596
+ assignToProperty ( container , aggregator ) ;
597
+
598
+ //create aggregations dictionary on `this` if it does not exist already
599
599
IAggregationContainer self = this ;
600
- if ( self . Aggregations == null ) self . Aggregations = new Dictionary < string , IAggregationContainer > ( ) ;
601
-
602
- //if the aggregator is a bucket aggregator (meaning it contains nested aggregations);
600
+ if ( self . Aggregations == null ) self . Aggregations = new Dictionary < string , IAggregationContainer > ( ) ;
601
+
602
+ //if the aggregator is a bucket aggregator (meaning it contains nested aggregations);
603
603
var bucket = aggregator as IBucketAggregation ;
604
604
if ( bucket != null && bucket . Aggregations . HasAny ( ) )
605
- {
606
- //make sure we copy those aggregations to the isolated container's
607
- //own .Aggregations container (the one that gets serialized to "aggs")
605
+ {
606
+ //make sure we copy those aggregations to the isolated container's
607
+ //own .Aggregations container (the one that gets serialized to "aggs")
608
608
IAggregationContainer d = container ;
609
609
d . Aggregations = bucket . Aggregations ;
610
- }
611
- //assign the aggregations container under Aggregations ("aggs" in the json)
610
+ }
611
+ //assign the aggregations container under Aggregations ("aggs" in the json)
612
612
self . Aggregations [ key ] = container ;
613
613
return this ;
614
614
}
@@ -618,31 +618,31 @@ public void Accept(IAggregationVisitor visitor)
618
618
if ( visitor . Scope == AggregationVisitorScope . Unknown ) visitor . Scope = AggregationVisitorScope . Aggregation ;
619
619
new AggregationWalker ( ) . Walk ( this , visitor ) ;
620
620
}
621
-
622
- //always evaluate to false so that each side of && equation is evaluated
623
- public static bool operator false( AggregationContainerDescriptor < T > a ) => false ;
624
-
625
- //always evaluate to false so that each side of && equation is evaluated
626
- public static bool operator true( AggregationContainerDescriptor < T > a ) => false ;
627
-
628
-
629
- public static AggregationContainerDescriptor < T > operator & ( AggregationContainerDescriptor < T > left , AggregationContainerDescriptor < T > right )
630
- {
631
- var d = new AggregationContainerDescriptor < T > ( ) ;
632
- var leftAggs = ( IDictionary < string , IAggregationContainer > ) ( ( IAggregationContainer ) left ) . Aggregations ;
633
- var rightAggs = ( IDictionary < string , IAggregationContainer > ) ( ( IAggregationContainer ) right ) . Aggregations ;
634
- foreach ( var kv in rightAggs )
635
- {
636
- if ( leftAggs . ContainsKey ( kv . Key ) )
637
- {
638
- var message = $ "Can not merge two { nameof ( AggregationContainerDescriptor < T > ) } 's";
639
- message += $ " { kv . Key } is defined in both";
640
- throw new Exception ( message ) ;
641
- }
642
- leftAggs . Add ( kv . Key , kv . Value ) ;
643
- }
644
- ( ( IAggregationContainer ) d ) . Aggregations = ( ( IAggregationContainer ) left ) . Aggregations ;
645
- return d ;
621
+
622
+ //always evaluate to false so that each side of && equation is evaluated
623
+ public static bool operator false( AggregationContainerDescriptor < T > a ) => false ;
624
+
625
+ //always evaluate to false so that each side of && equation is evaluated
626
+ public static bool operator true( AggregationContainerDescriptor < T > a ) => false ;
627
+
628
+
629
+ public static AggregationContainerDescriptor < T > operator & ( AggregationContainerDescriptor < T > left , AggregationContainerDescriptor < T > right )
630
+ {
631
+ var d = new AggregationContainerDescriptor < T > ( ) ;
632
+ var leftAggs = ( IDictionary < string , IAggregationContainer > ) ( ( IAggregationContainer ) left ) . Aggregations ;
633
+ var rightAggs = ( IDictionary < string , IAggregationContainer > ) ( ( IAggregationContainer ) right ) . Aggregations ;
634
+ foreach ( var kv in rightAggs )
635
+ {
636
+ if ( leftAggs . ContainsKey ( kv . Key ) )
637
+ {
638
+ var message = $ "Can not merge two { nameof ( AggregationContainerDescriptor < T > ) } 's";
639
+ message += $ " { kv . Key } is defined in both";
640
+ throw new Exception ( message ) ;
641
+ }
642
+ leftAggs . Add ( kv . Key , kv . Value ) ;
643
+ }
644
+ ( ( IAggregationContainer ) d ) . Aggregations = ( ( IAggregationContainer ) left ) . Aggregations ;
645
+ return d ;
646
646
}
647
647
}
648
- }
648
+ }
0 commit comments