gpt4 book ai didi

c# - 使用空格时,Azure 搜索的 search.in 不返回结果

转载 作者:行者123 更新时间:2023-11-30 14:22:46 31 4
gpt4 key购买 nike

我正在从我的 C# 应用程序调用 Azure 搜索。

当我尝试过滤产品类别时,仅当类别不包含任何空格时才会给出结果。

search.in(ProductCategory,'Garden')  // Works
search.in(ProductCategory,'Sport and Games') // Doesn't Work
search.in(ProductCategory,'Garden, Sport and Games') // Only shows 'Garden' results

documentation显示可以使用空格,所以我想知道为什么在使用空格时没有得到任何结果。

$filter=search.in(name, 'Roach motel, Budget hotel') // Sample from docs

它还指出 search.in(field, 'one,two, Three') 等于 field eq 'one' 或 field eq 'two' 或 field eq 'third '。但当我在我的例子中使用它时,ProductCategory eq 'Sport and Games' 它就可以工作了。

所以我认为它们之间存在某种差异。但我不知道它是什么。我首先认为这可能与字段 ProductCategory 不可搜索有关,但另一方面,它适用于非空间类别。另外,如果它的行为类似于 eg 那么它是一个过滤器而不是搜索,对吧..?

谁能解释一下其中的区别吗?

<小时/>

目前,我只是创建过滤器,不进行搜索,仅创建ProductCategory eq 'Sport and Games or ...',但当有人选择很多类别时,这可能会变得很长。

最佳答案

问题是,如果您不指定分隔符,search.in 会假定空格和逗号是分隔符。由于您的值中包含空格,因此您需要指定自己的分隔符参数。例如,假设您的值不包含逗号,您可以执行以下操作:

$filter=search.in(ProductCategory, 'Garden,Sport and Games', ',')

请注意 Garden 后面的逗号后面缺少空格。

一般来说,如果这些字符出现在文字值中,则不能使用这些字符作为分隔符。

您在我们的文档中提到的示例不正确。我们将确保它得到修复。抱歉造成困惑。

关于c# - 使用空格时,Azure 搜索的 search.in 不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48163513/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com