Azure 搜索 search.in 功能未按预期运行

Azuresearch search.in functionallity not working as expected

试图找出为什么以下过滤器 returns 不同的结果。

根据docs,我应该能够将and or条件与search in函数

结合使用

search.in(f, ‘a, b, c’) is semantically equivalent to f eq ‘a’ or f eq ‘b’ or f eq ‘c’, except that it executes much faster when the list of values is large.

但是下面的过滤returns不同的结果。但是为什么?

   // Returns nothing
   $count=true&$filter=companyGroupId eq 1595 and search.in(companyName, 'Sky Blue, Green Ice')

但如果我这样做

   // Returns expected results
    $count=true&$filter=companyGroupId eq 1595 and (companyName eq 'Sky Blue' or companyName eq 'Green Ice')

为什么结果对我来说如此不同,看起来它们应该是一样的。

我的公司名称 属性 看起来像这样

[IsFilterable]
[IsSortable]
[IsFacetable]
public string CompanyName { get; set; }

它们的不同之处在于 search.in 解析第二个参数的方式。由于您的值中有空格,因此您需要将自己的分隔符指定为 search.in 的第三个参数。默认行为是在空格和逗号处断开。试试这个:

search.in(companyName, 'Sky Blue|Green Ice', '|')

您可以找到使用 search.in here 的其他示例。