@@ -84,6 +84,9 @@ public interface IAggregationContainer
8484 [ JsonProperty ( "percentile_ranks" ) ]
8585 IPercentileRanksAggregaor PercentileRanks { get ; set ; }
8686
87+ [ JsonProperty ( "top_hits" ) ]
88+ ITopHitsAggregator TopHits { get ; set ; }
89+
8790 [ JsonProperty ( "aggs" ) ]
8891 [ JsonConverter ( typeof ( DictionaryKeysAreNotPropertyNamesJsonConverter ) ) ]
8992 IDictionary < string , IAggregationContainer > Aggregations { get ; set ; }
@@ -111,14 +114,14 @@ public class AggregationContainer : IAggregationContainer
111114 private ISignificantTermsAggregator _significantTerms ;
112115 private IPercentileRanksAggregaor _percentileRanks ;
113116
117+ private ITopHitsAggregator _topHits ;
114118 public IAverageAggregator Average { get ; set ; }
115119 public IValueCountAggregator ValueCount { get ; set ; }
116120 public IMaxAggregator Max { get ; set ; }
117121 public IMinAggregator Min { get ; set ; }
118122 public IStatsAggregator Stats { get ; set ; }
119123 public ISumAggregator Sum { get ; set ; }
120124 public IExtendedStatsAggregator ExtendedStats { get ; set ; }
121-
122125 public IDateHistogramAggregator DateHistogram
123126 {
124127 get { return _dateHistogram ; }
@@ -227,6 +230,12 @@ public IPercentileRanksAggregaor PercentileRanks
227230 set { _percentileRanks = value ; }
228231 }
229232
233+ public ITopHitsAggregator TopHits
234+ {
235+ get { return _topHits ; }
236+ set { _topHits = value ; }
237+ }
238+
230239 private void LiftAggregations ( IBucketAggregator bucket )
231240 {
232241 if ( bucket == null ) return ;
@@ -290,7 +299,9 @@ public class AggregationDescriptor<T> : IAggregationContainer
290299 IPercentileRanksAggregaor IAggregationContainer . PercentileRanks { get ; set ; }
291300
292301 ITermsAggregator IAggregationContainer . Terms { get ; set ; }
293-
302+
303+ ITopHitsAggregator IAggregationContainer . TopHits { get ; set ; }
304+
294305 public AggregationDescriptor < T > Average ( string name , Func < AverageAggregationDescriptor < T > , AverageAggregationDescriptor < T > > selector )
295306 {
296307 return _SetInnerAggregation ( name , selector , ( a , d ) => a . Average = d ) ;
@@ -429,6 +440,12 @@ public AggregationDescriptor<T> ValueCount(string name,
429440 return _SetInnerAggregation ( name , selector , ( a , d ) => a . ValueCount = d ) ;
430441 }
431442
443+ public AggregationDescriptor < T > TopHits ( string name ,
444+ Func < TopHitsAggregationDescriptor < T > , TopHitsAggregationDescriptor < T > > selector )
445+ {
446+ return _SetInnerAggregation ( name , selector , ( a , d ) => a . TopHits = d ) ;
447+ }
448+
432449 private AggregationDescriptor < T > _SetInnerAggregation < TAggregation > (
433450 string key ,
434451 Func < TAggregation , TAggregation > selector
0 commit comments