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

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