Azure 搜索返回带有日期筛选器的无效表达式
Azure search is returning Invalid Expression with Date Filter
我 运行 遇到了 Azure 搜索的问题,该搜索之前有效但现在有效
收到无效的表达。我错过了什么吗?
提交过滤器的日期类型 -
{ "name": "ModifiedDateTime",
"type": "Edm.DateTimeOffset",
"searchable":错误,
"filterable": 是的,
"facetable": 是的,
"sortable":正确}
enter image description here
Api-版本=2016-09-01-预览
请求-
{"queryType":"full","searchMode":"all","filter":"ModifiedDateTime ge 2018-12-12","search":null, "searchFields":null,"count":true}
错误 -
{
"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"
}
}
此错误是由回归引起的,现已修复。只有美国中西部的搜索服务受到影响。
我们缺少此案例的测试覆盖率,实际上我们从未打算支持它。虽然我们已经解决了这个问题以避免破坏向后兼容性,但我们可能会在未来的 API 版本中删除在过滤器中使用 Edm.Date
文字的功能。
在与日期进行比较时,您应该始终包括时间和偏移量部分。否则,您如何决定一天何时开始和下一天开始?对于普通日期,我们假设午夜 UTC,但此假设可能对您的用户无效。
我们建议像这样在 Edm.DateTimeOffset
字段上编写过滤器:
ModifiedDateTime ge 2018-12-12T00:00:00Z
Z 代表 UTC,Azure 搜索将所有 DateTimeOffset 值标准化为 UTC。
我 运行 遇到了 Azure 搜索的问题,该搜索之前有效但现在有效 收到无效的表达。我错过了什么吗? 提交过滤器的日期类型 -
{ "name": "ModifiedDateTime", "type": "Edm.DateTimeOffset", "searchable":错误, "filterable": 是的, "facetable": 是的, "sortable":正确}
enter image description here
Api-版本=2016-09-01-预览
请求-
{"queryType":"full","searchMode":"all","filter":"ModifiedDateTime ge 2018-12-12","search":null, "searchFields":null,"count":true}
错误 -
{ "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" } }
此错误是由回归引起的,现已修复。只有美国中西部的搜索服务受到影响。
我们缺少此案例的测试覆盖率,实际上我们从未打算支持它。虽然我们已经解决了这个问题以避免破坏向后兼容性,但我们可能会在未来的 API 版本中删除在过滤器中使用 Edm.Date
文字的功能。
在与日期进行比较时,您应该始终包括时间和偏移量部分。否则,您如何决定一天何时开始和下一天开始?对于普通日期,我们假设午夜 UTC,但此假设可能对您的用户无效。
我们建议像这样在 Edm.DateTimeOffset
字段上编写过滤器:
ModifiedDateTime ge 2018-12-12T00:00:00Z
Z 代表 UTC,Azure 搜索将所有 DateTimeOffset 值标准化为 UTC。