55
66namespace Nest
77{
8- [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter ) ) ]
8+ [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter < string , IAggregationContainer > ) ) ]
99 public class AggregationDictionary : IsADictionaryBase < string , IAggregationContainer >
1010 {
11- public AggregationDictionary ( ) : base ( ) { }
11+ public AggregationDictionary ( ) { }
1212 public AggregationDictionary ( IDictionary < string , IAggregationContainer > container ) : base ( container ) { }
1313 public AggregationDictionary ( Dictionary < string , AggregationContainer > container )
1414 : base ( container . ToDictionary ( kv => kv . Key , kv => ( IAggregationContainer ) kv . Value ) )
@@ -50,7 +50,7 @@ public static implicit operator AggregationDictionary(AggregationBase aggregator
5050 public interface IAggregationContainer
5151 {
5252 [ JsonProperty ( "meta" ) ]
53- [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter ) ) ]
53+ [ JsonConverter ( typeof ( VerbatimDictionaryKeysJsonConverter < string , object > ) ) ]
5454 IDictionary < string , object > Meta { get ; set ; }
5555
5656 [ JsonProperty ( "avg" ) ]
@@ -153,17 +153,17 @@ public interface IAggregationContainer
153153 IMinBucketAggregation MinBucket { get ; set ; }
154154
155155 [ 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+
167167 [ JsonProperty ( "moving_avg" ) ]
168168 IMovingAverageAggregation MovingAverage { get ; set ; }
169169
@@ -180,8 +180,8 @@ public interface IAggregationContainer
180180 IBucketSelectorAggregation BucketSelector { get ; set ; }
181181
182182 [ JsonProperty ( "sampler" ) ]
183- ISamplerAggregation Sampler { get ; set ; }
184-
183+ ISamplerAggregation Sampler { get ; set ; }
184+
185185 [ JsonProperty ( "geo_centroid" ) ]
186186 IGeoCentroidAggregation GeoCentroid { get ; set ; }
187187
@@ -256,14 +256,14 @@ public class AggregationContainer : IAggregationContainer
256256
257257 public IMinBucketAggregation MinBucket { get ; set ; }
258258
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+
267267 public IMovingAverageAggregation MovingAverage { get ; set ; }
268268
269269 public ICumulativeSumAggregation CumulativeSum { get ; set ; }
@@ -274,8 +274,8 @@ public class AggregationContainer : IAggregationContainer
274274
275275 public IBucketSelectorAggregation BucketSelector { get ; set ; }
276276
277- public ISamplerAggregation Sampler { get ; set ; }
278-
277+ public ISamplerAggregation Sampler { get ; set ; }
278+
279279 public IGeoCentroidAggregation GeoCentroid { get ; set ; }
280280
281281 public IMatrixStatsAggregation MatrixStats { get ; set ; }
@@ -373,14 +373,14 @@ public class AggregationContainerDescriptor<T> : DescriptorBase<AggregationConta
373373
374374 IMinBucketAggregation IAggregationContainer . MinBucket { get ; set ; }
375375
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+
384384 IMovingAverageAggregation IAggregationContainer . MovingAverage { get ; set ; }
385385
386386 ICumulativeSumAggregation IAggregationContainer . CumulativeSum { get ; set ; }
@@ -391,7 +391,7 @@ public class AggregationContainerDescriptor<T> : DescriptorBase<AggregationConta
391391
392392 IBucketSelectorAggregation IAggregationContainer . BucketSelector { get ; set ; }
393393
394- ISamplerAggregation IAggregationContainer . Sampler { get ; set ; }
394+ ISamplerAggregation IAggregationContainer . Sampler { get ; set ; }
395395
396396 IGeoCentroidAggregation IAggregationContainer . GeoCentroid { get ; set ; }
397397
@@ -531,20 +531,20 @@ public AggregationContainerDescriptor<T> MinBucket(string name,
531531
532532 public AggregationContainerDescriptor < T > SumBucket ( string name ,
533533 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+
548548 public AggregationContainerDescriptor < T > MovingAverage ( string name ,
549549 Func < MovingAverageAggregationDescriptor , IMovingAverageAggregation > selector ) =>
550550 _SetInnerAggregation ( name , selector , ( a , d ) => a . MovingAverage = d ) ;
@@ -567,16 +567,16 @@ public AggregationContainerDescriptor<T> BucketSelector(string name,
567567
568568 public AggregationContainerDescriptor < T > Sampler ( string name ,
569569 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+
580580 /// <summary>
581581 /// Fluent methods do not assign to properties on `this` directly but on IAggregationContainers inside `this.Aggregations[string, IContainer]
582582 /// </summary>
@@ -588,27 +588,27 @@ Func<TAggregator, TAggregatorInterface> selector
588588 where TAggregator : IAggregation , TAggregatorInterface , new ( )
589589 where TAggregatorInterface : IAggregation
590590 {
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
594594 var container = new AggregationContainer ( ) { Meta = aggregator . Meta } ;
595595
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
599599 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);
603603 var bucket = aggregator as IBucketAggregation ;
604604 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")
608608 IAggregationContainer d = container ;
609609 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)
612612 self . Aggregations [ key ] = container ;
613613 return this ;
614614 }
@@ -618,31 +618,31 @@ public void Accept(IAggregationVisitor visitor)
618618 if ( visitor . Scope == AggregationVisitorScope . Unknown ) visitor . Scope = AggregationVisitorScope . Aggregation ;
619619 new AggregationWalker ( ) . Walk ( this , visitor ) ;
620620 }
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 ;
646646 }
647647 }
648- }
648+ }
0 commit comments