0
votes

I am running into an issue with Azure search which was working before but now receiving Invalid Expression. Am I missing something. Date Type of the filter filed-

{ "name": "ModifiedDateTime", "type": "Edm.DateTimeOffset", "searchable": false, "filterable": true, "facetable": true, "sortable": true }

enter image description here

Api-version=2016-09-01-Preview

Request-

{"queryType":"full","searchMode":"all","filter":"ModifiedDateTime ge 2018-12-12","search":null,"searchFields":null,"count":true}

Error -

{ "error": { "code": "", "message": "Invalid expression: Literal '2018-12-12' of unsupported data type 'Date' was found. Please use a literal that matches the type of the field in the expression.\r\nParameter name: $filter" } }

1

1 Answers

2
votes

This error was caused by a regression that has since been fixed. Only Search services in West Central US were affected.

We had missing test coverage for this case, which we actually never intended to support. Although we have fixed this to avoid breaking backward compatibility, we may remove the ability to use Edm.Date literals in filters in a future API version.

You should always include the time and offset portions as well when comparing with dates. Otherwise, how do you decide when one day starts and the next begins? We assume midnight UTC for plain dates, but this assumption may not be valid for your users.

We recommend writing filters on Edm.DateTimeOffset fields like this instead:

ModifiedDateTime ge 2018-12-12T00:00:00Z

The Z is for UTC, to which Azure Search normalizes all DateTimeOffset values.