search - Azure 搜索分层搜索字段

标签 search odata azure-cognitive-search

我正在评估一个项目的 Azure 搜索。 MSDN 文章仅具有扁平化架构结构。下面是我正在查看的示例场景。

下面是“Project”类,引用了“Question”类的列表。 “问题”有它自己的一组字段

public class Project
    {
        public Guid Id
        {
            get;
            set;
        }

        public string Owner
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

        public List<Question> QuestionList
        {
            get;
            set;
        }

        public bool Disable
        {
            get;
            set;
        }

}

public class Question
    {
        public Guid Id { get; set; }

        public string Title { get; set; }

        public string Description { get; set; }
    }

Below will be Index Schema for Project

  • Id - Edm.String
  • 所有者 - Edm.String
  • 标题 - Edm.String
  • 问题列表 - 集合(Edm.String)

问题

  • 是否可以指定 QuestionList 中的每个项目都具有分层数据?
  • 是否可以仅在“问题”的“标题”内搜索?
  • 我看到的唯一可能性是单独为“问题”创建索引并使用它

我在 MSDN 中看到的唯一相关的一点是下面的段落,我无法理解它

Levels in faceted navigation

As noted, there is no direct support for nesting facets in a hierarchy. Out of the box, faceted navigation only supports one level of filters. However, workarounds do exist. You can encode a hierarchical facet structure in a Collection(Edm.String) with one entry point per hierarchy. Implementing this workaround is beyond the scope of this article, but you can read about collections in OData by Example.

最佳答案

对于您的第一个问题,Azure 搜索不允许使用分层数据类型,并且要进行搜索,您需要像对创建为集合的 QuestionList 字段那样展平数据。如果您询问如何根据此集合中的项目筛选结果,可以使用 OData 表达式来实现,例如 $filter=QuestionList/any(t: t eq 'Question1') ( https://msdn.microsoft.com/en-us/library/azure/dn798921.aspx )

我认为对于你的第二个问题,你有兴趣只搜索“标题”“问题”,对吗?为此,您可以使用 SearchFields 参数 ( https://msdn.microsoft.com/en-us/library/azure/dn798927.aspx )。

利亚姆

关于search - Azure 搜索分层搜索字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28507545/

相关文章:

php - 如何向 LIKE 查询添加更多选项

java - OData 服务器 API 和表达式语法、文字和成员

Azure 搜索和破折号

odata - 仅获取 OData 中实体的属性定义

azure - 为什么该字段不接受词法分析

api - 在 Azure 搜索查询中转义单引号

java - 如何使用 Java HTTP 搜索数据?

search - Elasticsearch 。带有破折号的字符串的范围查询

linux - 在 linux/unix 中搜索

c# - 如何在 UWP(.NET 通用应用程序)中连接到 MSSQL 服务器