Description
First of all I want to point out I'm very happy that with 8.13 and that it finally feels like we're moving towards the point where we can actually depreciate the nest client in our solution rather than using two clients at once.
When migrating however, I noticed that most of the changes that broke our code required rewrites that do the same thing, just in more code, most of which feels unnecessary. Maybe I've overlooked some obvious solutions though, so I'd be happy for suggestions.
Otherwise I want to at least point them out here, even though I fully understand these probably have not been at the top of the priorities when writing 8.13, so here are some examples.
First and foremost obviously the aggregation change, that requires an additional add, straight from the release notes:
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 addition, I find subbaggregations alot clearer in the original example.
MatchAll now needs a parameter:
q => q.MatchAll()
to:
q => q.MatchAll(m => m.QueryName("all"))
Indexing:
await this.Client.IndexAsync(elasticCustomer, indexName, token);
to:
await this.Client.IndexAsync(elasticCustomer, i => i.Index(indexName), token);
Highlighting (simplified):
private HighlightField HighlightField => new() { PreTags = new List<string> { "<span style=\"style\">" }, PostTags = new List<string> { "</span>" } };
.Highlight(h => h.Fields(fs => fs.Add(new Field("field"), this.HighlightField)))
to:
private HighlightField HighlightField => new() { PreTags = new List<string> { "<span style=\"style\">" }, PostTags = new List<string> { "</span>" } };
.Highlight(h => h.Fields(fs => fs.Add(new Field("field"), hf => hf.PreTags(this.HighlightField.PreTags).PostTags(this.HighlightField.PostTags))))
Again I'm grateful for the effort I can live with all these, but I figured I'd at least point them out in case some of these are just oversights (e.g. MatchAll).