Searching between dates using OData

Azure Search uses OData expressions syntax to build filter queries when searching within a searchable section of data.

Searching within a data range indicates that you should use a DateTimeOffSet, which is the data type stored in the, but it is easier to search using the following format

DateTime.Now.ToString(“yyyy-MM-dd’T’HH:mm:ss-00:00”);

To search between two dates, the filter list needs to be in the following format

$filter=year ge 2016-01-01T00:00:00-00:00 and year le 2016-12-31T23:59:59-00:00

If you are passing this via the REST API, URL encode the string before passing it to the service.
If you are using the .NET Azure package from NUGET, create a new Search Parameters object and pass the string to the Filter parameter and the encoding will happen automatically.

https://www.nuget.org/packages/Microsoft.Azure.Search 
https://docs.microsoft.com/en-us/rest/api/searchservice/supported-data-types
https://docs.microsoft.com/en-us/rest/api/searchservice/OData-Expression-Syntax-for-Azure-Search

Searching Collection(Edm.String) with oData in .net

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'))