Reputation: 4803
I just updated elastic search from 2.3.4 to 5.0.1, and nest C# nuget package to the latest 2.4.7
I have the following nest query:
SourceFilter sourceFilter = new SourceFilter()
{
Include = Infer.Fields<Page>(p => p.Category, p => p.Title)
};
MultiMatchQuery multiMatchQuery = new MultiMatchQuery()
{
Fields = Infer.Fields<Page>(p => p.Title, p => p.MetaDescription, p => p.Keywords),
Type = TextQueryType.PhrasePrefix,
Query = search.Term
};
var searchQuery = new SearchRequest<Page>()
{
From = search.ResultsFrom,
Size = search.ResultsSize,
Source = sourceFilter,
Query = multiMatchQuery
};
var searchResponse = client.Search<Page>(searchQuery);
I'm getting the following error back from elastic:
Deprecated field [include] used, expected [includes] instead
Commenting out the SourceFilter
allows the query to run through.
Is there a different way to use SourceFilter
?
Upvotes: 0
Views: 752
Reputation: 9444
The syntax for Include
should be Includes
instead of Include
according to source filtering usage. Even the error which you've mentioned above concise the incorrect syntax of Include
. I ain't sure about the version compatibility though. If I reproduce yours, it should look something like this:
Source = new SourceFilter()
{
Includes = Infer.Fields<Page>(p => p.Category, p => p.Title)
};
Upvotes: 1
Reputation: 125498
If you're running against Elasticsearch 5.0.1, you should use a 5.x version of NEST; the latest 5.x version on nuget is 5.0.0-rc3 (a prerelease) at this time, with 5.0.0 to come out very soon.
5.x contains the Includes
property on ISourceFilter
that Kulasangar highlights in his answer.
Upvotes: 1