Unfortunately there is no proper documentations for the v8.x .NET client yet.
The following code is an example how to use the new elastic.client.elasticsearch package in compare to the v7 Nest package.
// v8.x version sample code
var searchRequest = new SearchRequest<YourDocumentEntity>()
{
Query = new SimpleQueryStringQuery()
{
Query = "the text you want to search",
Fields = new Field[]
{
// two sample fields:
new("title", boost: 2),
new("body", boost: 1)
},
DefaultOperator = Operator.Or,
MinimumShouldMatch = 3,
}
Highlight = new Highlight()
{
PreTags = ["<mark>"],
PostTags = ["</mark>"],
Encoder = HighlighterEncoder.Html,
Fields = new Dictionary<Field, HighlightField>
{
{ new Field("title"), new HighlightField() { PreTags = ["<mark>"], PostTags = ["</mark>"] }},
{ new Field("body"), new HighlightField() { PreTags = ["<mark>"], PostTags = ["</mark>"] }},
},
}
};
var searchResponse = await _client.SearchAsync<YourDocumentEntity>(searchRequest);
And the same code using Nest will be like this:
// v7.17 sample code
var searchResponse = await _client.SearchAsync<YourDocumentEntity>(s => s
.Query(q => q
.SimpleQueryString(m => m
.Query("the text you want to search")
.Fields(f => f
.Field(p => p.Title, boost: 2)
.Field(p => p.Body)
)
.DefaultOperator(Operator.Or)
.MinimumShouldMatch(3)
)
)
.Highlight(h => h
.PreTags("<mark>")
.PostTags("</mark>")
.Encoder(HighlighterEncoder.Html)
.Fields(
f => f.Field(p => p.Title).PreTags("<mark>").PostTags("</mark>"),
f => f.Field(p => p.Body).PreTags("<mark>").PostTags("</mark>")
)
)
);