You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[1. Improved usability of `CompositeAggregation`](#1-composite-aggregation)
27
+
28
+
### Breaking changes
29
+
30
+
#### 1. Improved usability of `CompositeAggregation`[#1-composite-aggregation]
31
+
32
+
**Impact**: Low.
33
+
34
+
The type of the `Sources` property has been changed from `ICollection<IDictionary<string, CompositeAggregationSource>>` to `ICollection<KeyValuePair<string, CompositeAggregationSource>>`. This corresponds to the Elasticsearch standard for modeling ordered dictionaries in the REST API.
35
+
36
+
`CompositeAggregationSource` is now also a container (similar to `Aggregation`, `Query`, etc.). This change improves usability due to specialized code generation. For example, implicit conversion operators from all existing variants (`CompositeTermsAggregation`, `CompositeHistogramAggregation`, etc.) to `CompositeAggregationSource` are now generated.
37
+
38
+
As a consequence, the object initializer syntax changes as follows:
In addition, this change allows optimized Fluent syntax to be generated, which ultimately avoids a previously existing ambiguity:
107
+
108
+
```csharp
109
+
// 9.1.7 and below
110
+
111
+
vardescriptor=newSearchRequestDescriptor()
112
+
.Aggregations(aggs=>aggs
113
+
.Add("my_composize", agg=>agg
114
+
.Composite(composite=>composite
115
+
.Sources( // <-- 'params' overload
116
+
x=>x.Add("my_terms", x=>x.Terms(/* ... */)), // dictionary 1 with a single entry
117
+
x=>x.Add("my_histo", x=>x.Histogram(/* ... */)) // dictionary 2 with a single entry
118
+
)
119
+
)
120
+
)
121
+
);
122
+
123
+
// 9.1.8 and above
124
+
125
+
vardescriptor=newSearchRequestDescriptor()
126
+
.Aggregations(aggs=>aggs
127
+
.Add("my_composize", agg=>agg
128
+
.Composite(composite=>composite
129
+
.Sources(sources=>sources
130
+
.Add("my_terms", x=>x.Terms(/* ... */))
131
+
.Add("my_histo", x=>x.Histogram(/* ... */))
132
+
)
133
+
)
134
+
)
135
+
);
136
+
```
137
+
138
+
The old syntax was tricky because the 9.1.8 example also compiled successfully, but the `.Add` referred to the first dictionary both times. This ultimately resulted in a list with only one dictionary, which had multiple entries, and thus an invalid request.
0 commit comments