在Azure搜索中筛选Collection(Edm.String)类型字段

时间:2019-03-14 18:34:47

标签: azure-search

我有一个索引,该索引具有一个Collection(Edm.String)类型的字段,如下所示,该字段是可工作的且可过滤的。

Index definition

但是当我对有效负载进行如下查询以进行过滤时: {
     “ count”:是的,
     “搜索”:“无法连接到Azure SQL数据库”,
     “ searchFields”:“内容,关键字”,
     “ select”:“关键字”,      “ facets”:[“源,排序:计数”,“子源,排序:计数”],      “ filter”:“关键字/任何(t:search.in(t,'sql server database')))”,      “顶部”:6 }

我看到这样的结果,其中的关键短语甚至没有完整的值“'sql server database”。为什么会这样呢?筛选器如何对Azure搜索中的集合类型起作用?如何进行精确过滤?

"value": [
    {
        "@search.score": 0.9469998,
        "keyphrases": [
            "windows azure",
            "sql azure",
            "web application",
            "database",
            "desktop"
        ]
    },
    {
        "@search.score": 0.7976283,
        "keyphrases": [
            "Entity Framework Code",
            "modelBuilder",
            "base tables",
            "SQL Azure",
            "one-to-one mapping",
            "factory",
            "pre",
            "large numbers of tables",
            "partitioned view",
            "simple POCO",
            "typical partitioning",
            "horizontal partitioning strategy",
            "CHECK CONSTRAINTs",
            "gt",
            "EntityName",
            "lt",
            "ToTable",
            "DbContext class",
            "UNION",
            "project",
            "OnModelCreating event",
            "foo",
            "file groups",
            "bar",
            "instance",
            "peform",
            "runtime",
            "database",
            "Fluent API",
            "metadata"
        ]
    },

谢谢。

1 个答案:

答案 0 :(得分:1)

search.in测试字段或集合值是否包含在定界的值列表中(如here所述)。所以这个表达式:

keyphrases/any(t: search.in(t, 'sql server database'))

与此等效(因为空格是search.in的默认定界符之一):

keyphrases/any(t: t eq 'sql' or t eq 'server' or t eq 'database')

如果您要查找短语“ sql server database”(包括大小写和空格),则过滤器应为:

keyphrases/any(t: t eq 'sql server database')