Azure search allows for an array of strings to be stored against a record.

You can set up the field either by creating it directly in the azure portal, or creating a property and adding the following attributes.

[IsSearchable, IsFilterable, IsFacetable]
 public string[] Category { get; set; }

The IsFilterable  must be set, otherwise the framework will throw an exception

The .net SDK gives the option to set search parameters when making a query which translates into a HTTP request using the oData syntax.

https://docs.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search

The documentation shows how to find a single item in the list, but not multiple options in the same list. To search for options 1 or 2 or 3 in the Category property, the filter will need to be formed as follows

$filter=(category/any(c: c eq '1') or category/any(c: c eq '2') or 
category/any(c: c eq '2'))

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s