Reputation: 33988
I am using Azure Search and I want to make a simple filter expression using Azure Search SDK, however I cant find documentation in how to do it by code when I want to filter on a specific field.
This work on the Search explorer
However, in Code, this doesnt work;
I get a syntax error:
Console.Write("Apply a filter to the index to find roles with a rolename:Usuario, ");
Console.WriteLine("and return the id and name:\n");
parameters =
new SearchParameters()
{
Filter = "RoleName:Partner",
Select = new[] { "id", "RoleName" }
};
results = indexClient.Documents.Search<Role>("*", parameters);
WriteDocuments(results);
The code is based on this sample:
Upvotes: 0
Views: 1391
Reputation: 980
You can try
new SearchParameters()
{
Filter = "RoleName eq 'Partner'",
Select = new[] { "id", "RoleName" }
};
Generally speaking, since the SDK is open source, you can use the unit tests on GitHub to find examples on how to use some of the more common features.
Upvotes: 3