1

Looking at the docs we should be able to create a new source filter like so

new SearchRequest<Project>
{
    Source = new SourceFilter
    {
        Include = Fields<Project>(p => p.Name, prop => prop.StartedOn)
    }
}

The issue I'm facing is that Fields isn't typed and doesn't have a constructor.

How do I go about making a Fields for use in sourceFilters, queries etc?

2
  • Which version of NEST do you use? Commented Aug 23, 2016 at 17:47
  • @Rob I've got the latest off Nuget 2.4.3 Commented Aug 23, 2016 at 17:48

1 Answer 1

4

You can find Fields<> method in class Infer, so change example code to

new SearchRequest<Project>
{
    Source = new SourceFilter
    {
        Include = Infer.Fields<Project>(p => p.Name, prop => prop.StartedOn)
    }
}

Also you can import this static class in your cs file with using static Nest.Infer;, so you will be able to use this example as it is.

Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.