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

标签 azure-cognitive-search

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

具体来说,我们看到/search 端点的这个 json post 找到了版本 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-预览及以上版本):

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

ps。这是我们当前围绕 not(doubleField ge -INF) 和 doubleField ne null 的工作

最佳答案

从 API 版本 2016-09-01-Preview 开始,Azure 搜索现在根据 clarified 实现 IEEE 754 语义,以便与 NaN 进行比较。 OData V4.01 specification .

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

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

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

事实证明,允许对 NaN 进行索引是有问题的,我们正在考虑在未来的 API 版本中完全禁止它。

关于azure-cognitive-search - 在 2016-09-01-Preview 回归后,是否有一种新方法可以与 Azure 搜索中的 odata 筛选器中的 NaN 进行比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52478861/

相关文章:

c# - $filter 上关于 "invalid expression"的 Azure 搜索错误是什么?

azure-cognitive-search - Azure 搜索评分

Azure 认知搜索 - 返回完整的 json 作为 SearchDocument?

lucene - 如何在 Azure 认知搜索中进行分页

php - 如何: Paginated Search in Azure Search using PHP

azure - 将 top 与 Azure 搜索建议结合使用

Azure 认知搜索,当查询与开头的值匹配时,过滤器会给出结果

azure - Azure 搜索 .NET 客户端 API 中的空间搜索

azure - 如何获取azure搜索的所有结果?

Azure 搜索 Multi-Tenancy 策略、成本和建议