在 2016-09-01-Preview 回归后,是否有一种新方法可以与 Azure 搜索中的 odata 筛选器中的 NaN 进行比较?

Is there a new way to compare to NaN in an odata filter in Azure Search after the regression in 2016-09-01-Preview?

在 2016-09-01-Preview 及更高版本中通过其余 API 查找与 Edm.Double 字段中的 NaN 匹配的文档的官方方法是什么?

具体来说,我们看到这个 json post 到 /search 端点在版本 2016-09-01 中找到文档,但在版本 2016-09-01-Preview 及更高版本中找不到。

{"filter":"(doublefield eq NaN)","select":"id","top":10,"skip":0,"count":true}

下方完整转载信息

索引定义:

{  
   "name":"indexnamehere",
   "fields":[  
      {  
         "name":"doublefield",
         "type":"Edm.Double",
         "searchable":false,
         "filterable":true,
         "sortable":true,
         "facetable":false,
         "key":false,
         "retrievable":true
      },
      {  
         "name":"id",
         "type":"Edm.String",
         "searchable":false,
         "filterable":true,
         "sortable":true,
         "facetable":false,
         "key":true,
         "retrievable":true
      }
   ]
}

文件:

{  
   "value":[  
      {  
         "id":"60660cd3b9e24d26ae3609926f44aead",
         "doublefield":"NaN",
         "@search.action":"upload"
      },
      {  
         "id":"70660cd3b9e24d26ae3609926f44aead",
         "doublefield":"2",
         "@search.action":"upload"
      }
   ]
}

查询 1 - 查找文档:

{"filter":"(doublefield eq 2)","select":"id","top":10,"skip":0,"count":true}

查询 2 - 找不到文档(在 2016-09-01-Preview 及更高版本中):

{"filter":"(doublefield eq NaN)","select":"id","top":10,"skip":0,"count":true}

ps。这是我们目前围绕 not(doubleField ge -INF) and doubleField ne null

的工作

从 API 版本 2016-09-01-Preview 开始,Azure 搜索现在根据 clarified OData V4.01 specification.[=19= 实施 IEEE 754 语义与 [=10= 进行比较]

The special value NaN is not equal to anything, even to itself.

在此之前,NaN 比较是不可靠的。特别是,不等式运算符的行为不正确,甚至在不同的搜索服务之间也不一致。

我们在 API 版本边界上进行了此更改以避免破坏现有应用程序,但是使用 2016-09-01-Preview 或更高版本的未来应用程序无法在双字段中检测到 NaN。如果您需要为 Edm.Double 字段设置某种标记值,我们建议您改用 null,因为您可以使用过滤器检查 null

允许 NaN 被编入索引已被证明是有问题的,我们正在考虑在未来的 API 版本中完全禁止它。