@@ -14,24 +14,35 @@ public partial class AggregateDictionary
1414
1515 public bool IsEmptyTerms ( string key ) => ! BackingDictionary . TryGetValue ( key , out var agg ) || agg is EmptyTermsAggregate ;
1616
17- public bool TryGetStringTerms ( string key , out StringTermsAggregate ? aggregate )
18- {
19- aggregate = null ;
20-
21- if ( BackingDictionary . TryGetValue ( key , out var agg ) && agg is StringTermsAggregate stringTermsAgg )
22- {
23- aggregate = stringTermsAgg ;
24- return true ;
25- }
26-
27- return false ;
28- }
29-
30- public AvgAggregate ? Average ( string key ) => TryGet < AvgAggregate ? > ( key ) ;
31-
32- public TermsAggregate < string > Terms ( string key ) => Terms < string > ( key ) ;
33-
34- public TermsAggregate < TKey > Terms < TKey > ( string key )
17+ // This should be autogenerated if we want to include this.
18+ //public bool TryGetStringTerms(string key, out StringTermsAggregate? aggregate)
19+ //{
20+ // aggregate = null;
21+
22+ // if (BackingDictionary.TryGetValue(key, out var agg) && agg is StringTermsAggregate stringTermsAgg)
23+ // {
24+ // aggregate = stringTermsAgg;
25+ // return true;
26+ // }
27+
28+ // return false;
29+ //}
30+
31+ public AvgAggregate ? GetAverage ( string key ) => TryGet < AvgAggregate ? > ( key ) ;
32+
33+ /// <summary>
34+ /// WARNING: EXPERIMENTAL API
35+ /// <para>This API provides simplified access to terms aggregations.</para>
36+ /// </summary>
37+ /// <remarks>Experimental APIs are subject to changes or removal and should be used with caution.</remarks>
38+ public TermsAggregate < string > GetTerms ( string key ) => GetTerms < string > ( key ) ;
39+
40+ /// <summary>
41+ /// WARNING: EXPERIMENTAL API
42+ /// <para>This API provides simplified access to terms aggregations.</para>
43+ /// </summary>
44+ /// <remarks>Experimental APIs are subject to changes or removal and should be used with caution.</remarks>
45+ public TermsAggregate < TKey > GetTerms < TKey > ( string key )
3546 {
3647 if ( ! BackingDictionary . TryGetValue ( key , out var agg ) )
3748 {
@@ -59,12 +70,12 @@ public TermsAggregate<TKey> Terms<TKey>(string key)
5970 {
6071 var key = item . Key ;
6172 var value = item . Value ;
62- dict . Add ( key , new TermsBucket < TKey > { DocCount = value . DocCount , DocCountError = value . DocCountError , Key = GetKeyFromBucketKey < TKey > ( value . Key ) , KeyAsString = value . Key } ) ;
73+ dict . Add ( key , new TermsBucket < TKey > ( value . BackingDictionary ) { DocCount = value . DocCount , DocCountError = value . DocCountError , Key = GetKeyFromBucketKey < TKey > ( value . Key ) , KeyAsString = value . Key } ) ;
6374 }
6475 buckets = new ( dict ) ;
6576 } , a =>
6677 {
67- buckets = new ( a . Select ( b => new TermsBucket < TKey > { DocCount = b . DocCount , DocCountError = b . DocCountError , Key = GetKeyFromBucketKey < TKey > ( b . Key ) , KeyAsString = b . Key } ) . ToReadOnlyCollection ( ) ) ;
78+ buckets = new ( a . Select ( b => new TermsBucket < TKey > ( b . BackingDictionary ) { DocCount = b . DocCount , DocCountError = b . DocCountError , Key = GetKeyFromBucketKey < TKey > ( b . Key ) , KeyAsString = b . Key } ) . ToReadOnlyCollection ( ) ) ;
6879 } ) ;
6980
7081 return new TermsAggregate < TKey >
@@ -83,12 +94,12 @@ public TermsAggregate<TKey> Terms<TKey>(string key)
8394 {
8495 var key = item . Key ;
8596 var value = item . Value ;
86- dict . Add ( key , new TermsBucket < TKey > { DocCount = value . DocCount , DocCountError = value . DocCountError , Key = GetKeyFromBucketKey < TKey > ( value . Key ) , KeyAsString = value . KeyAsString } ) ;
97+ dict . Add ( key , new TermsBucket < TKey > ( value . BackingDictionary ) { DocCount = value . DocCount , DocCountError = value . DocCountError , Key = GetKeyFromBucketKey < TKey > ( value . Key ) , KeyAsString = value . KeyAsString } ) ;
8798 }
8899 buckets = new ( dict ) ;
89100 } , a =>
90101 {
91- buckets = new ( a . Select ( b => new TermsBucket < TKey > { DocCount = b . DocCount , DocCountError = b . DocCountError , Key = GetKeyFromBucketKey < TKey > ( b . Key ) , KeyAsString = b . KeyAsString } ) . ToReadOnlyCollection ( ) ) ;
102+ buckets = new ( a . Select ( b => new TermsBucket < TKey > ( b . BackingDictionary ) { DocCount = b . DocCount , DocCountError = b . DocCountError , Key = GetKeyFromBucketKey < TKey > ( b . Key ) , KeyAsString = b . KeyAsString } ) . ToReadOnlyCollection ( ) ) ;
92103 } ) ;
93104
94105 return new TermsAggregate < TKey >
@@ -107,12 +118,12 @@ public TermsAggregate<TKey> Terms<TKey>(string key)
107118 {
108119 var key = item . Key ;
109120 var value = item . Value ;
110- dict . Add ( key , new TermsBucket < TKey > { DocCount = value . DocCount , DocCountError = value . DocCountError , Key = GetKeyFromBucketKey < TKey > ( value . Key ) , KeyAsString = value . KeyAsString } ) ;
121+ dict . Add ( key , new TermsBucket < TKey > ( value . BackingDictionary ) { DocCount = value . DocCount , DocCountError = value . DocCountError , Key = GetKeyFromBucketKey < TKey > ( value . Key ) , KeyAsString = value . KeyAsString } ) ;
111122 }
112123 buckets = new ( dict ) ;
113124 } , a =>
114125 {
115- buckets = new ( a . Select ( b => new TermsBucket < TKey > { DocCount = b . DocCount , DocCountError = b . DocCountError , Key = GetKeyFromBucketKey < TKey > ( b . Key ) , KeyAsString = b . KeyAsString } ) . ToReadOnlyCollection ( ) ) ;
126+ buckets = new ( a . Select ( b => new TermsBucket < TKey > ( b . BackingDictionary ) { DocCount = b . DocCount , DocCountError = b . DocCountError , Key = GetKeyFromBucketKey < TKey > ( b . Key ) , KeyAsString = b . KeyAsString } ) . ToReadOnlyCollection ( ) ) ;
116127 } ) ;
117128
118129 return new TermsAggregate < TKey >
0 commit comments