In v10 of Azure Search SDK, I was able to specify exactly which fields to search in an index by taking advantage of SearchParameters class. In v11, I see there is SearchOptions, but the SearchFields parameter is get only. In v10, SearchFields has a setter.
How do I choose which fields to search on in v11?
You can call .Add()
on the SearchFields
property:
var options = new SearchOptions();
options.SearchFields.Add("field1");
options.SearchFields.Add("field2");
Or you can use C#'s list initializer syntax:
var options = new SearchOptions() { SearchFields = { "field1", "field2" } };
Example adapted from this GitHub issue.