Introduction
This version of the client is the first one generated by a completely revised code generator. In addition to more than 200 new endpoints, which were not yet supported in 8.12.1, 8.13.0 finally supports all aggregations and many other previously unavailable features.
The support of these new functions is accompanied by some breaking changes. In the next section, we have been working to document all of these changes and show the new usage with code examples. If you come across any undocumented changes, please feel free to open an issue
Although the most common endpoints have been tested by hand, there is a possibility that this version contains a few minor bugs. If you come across such a bug, please let us know. Over the next few weeks, we will closely monitor the issue tracker and respond quickly with appropriate patch releases.
Breaking Changes
Aggregations
The aggregation name and the sub-aggregations property was pulled out of the actual aggregation variant classes. The usage changes from:
var aggExampleResponse = await client.SearchAsync<StockData>(s => s
.Aggregations(aggs => aggs
.DateHistogram("by-month", dh => dh
.CalendarInterval(CalendarInterval.Month)
.Field(fld => fld.Date)
.Aggregations(subaggs => subaggs
.Sum("trade-volumes", sum => sum.Field(fld => fld.Volume))
)
)
)
);
to:
var aggExampleResponse = await client.SearchAsync<StockData>(s => s
.Aggregations(aggs => aggs
.Add("by-month", agg => agg
.DateHistogram(dh => dh
.CalendarInterval(CalendarInterval.Month)
.Field(fld => fld.Date)
)
.Aggregations(subaggs => subaggs
.Add("trade-volumes", agg => agg
.Sum(sum => sum.Field(fld => fld.Volume))
)
)
)
)
);
In the response, the sub-aggregations are no longer part of the bucket class itself, but must be accessed through the Aggregations
property instead. Usage changes from:
var monthlyBuckets = aggExampleResponse.Aggregations?.GetDateHistogram("by-month")?.Buckets ?? Array.Empty<DateHistogramBucket>();
foreach (var monthlyBucket in monthlyBuckets)
{
var volume = monthlyBucket.GetSum("trade-volumes");
Console.WriteLine($"{monthlyBucket.Key} : {volume}");
}
to:
var monthlyBuckets = aggExampleResponse.Aggregations?.GetDateHistogram("by-month")?.Buckets ?? Array.Empty<DateHistogramBucket>();
foreach (var monthlyBucket in monthlyBuckets)
{
var volume = monthlyBucket.Aggregations.GetSum("trade-volumes");
Console.WriteLine($"{monthlyBucket.Key} : {volume}");
}
Please as well note, that it is no longer possible to compose a dictionary/list of aggregations using the &&
operator.
Query
Query variants no longer derive from SearchQuery
. This has some implications on usage. Instead of being able to e.g. use logical operators on query variants like this:
var myQuery = new TermQuery("field") { Value = "a" } || new TermQuery("field") { Value = "b" };
// => BoolQuery variant
you have to wrap the query into the container first:
var myQuery = Query.Term(new("field") { Value = "a" }) || Query.Term(new("field") { Value = "b" });
// => Query container that wraps a BoolQuery variant
Deprecation of synchronous APIs
This version deprecates all synchronous endpoint API methods in the ElasticsearchClient
class (and namespaced versions).
What's Changed
- Regenerate client for 8.13 (#8071)
Full Changelog: 8.12.1...8.13.0