查找没有时间部分的 Azure 搜索日期

Find Azure Search date without time part

我找不到仅使用日期从 Azure 搜索中获取日期的方法。

索引中的日期如下:“2019-10-15T18:00:00Z”,“2019-10-22T18:00:00Z”,“2019-10-29T18:00:00Z”

如果我尝试 StartDate/any(s: s eq 2019-10-15T18:00:00Z) 我会得到结果 但是 StartDate/any(s: s eq 2019-10-15) 什么都没有出现

我试过像这样使用 date OData 函数:StartDate/any(s: date(s) eq 2019-10-15) 但我收到错误消息“不支持函数 'date'”。

有什么方法可以不使用时间部分来获取日期吗?

Date and time values represented in the OData V4 format: yyyy-MM-ddTHH:mm:ss.fffZ or yyyy-MM-ddTHH:mm:ss.fff[+|-]HH:mm. Precision of DateTimeOffset fields is limited to milliseconds. If you upload DateTimeOffset values with sub-millisecond precision, the value returned will be rounded up to milliseconds.

当您将带有时区信息的 DateTimeOffset 值上传到索引时,Azure 搜索会将这些值规范化为 UTC

参考 Azure 搜索中的 supported data types

从 api-版本 2019-05-06-Preview 开始,将不再支持在 Azure 搜索的筛选器中使用日期文字。这是我们从未打算支持的 "accidental feature"。您没有得到任何结果的原因是因为从 Edm.DateEdm.DateTimeOffset 的隐式转换假设时间是 UTC 午夜,而索引中的日期是 UTC 下午 6 点。

我们建议在过滤器中明确提供时间和偏移量(或 Z 表示 UTC)以避免此问题。

如果您希望 Azure 搜索本身支持 Edm.Date 类型的字段和筛选器,请投票给 this User Voice suggestion