I have this query:
.Search<Person>("person", s => s
.Index("person")
.Source(s => s
.Includes(i => i
.Fields(
f => f.Id,
)
)
)
.Query(q => q
.Match(m => m
.Field(personname)
.Query(search)
)
)
)
and I try to make include dynamic with if-else in the code below:
public Func<SourceFilterDescriptor<Person>, ISourceFilter> PersonIncludeBuilder
{
var fields = new List<Func<FieldsDescriptor<Person>, FieldsDescriptor<Person>>>();
fields.Add(f => f.Field(f => f.Id));
if(includePersonName)
{
fields.Add(f => f.Field(f => f.Name));
}
return //How to convert to Func<SourceFilterDescriptor<Person>, ISourceFilter> or are they other way to do it?;
}
Am I on the right track or are they otherways to do it?