【问题标题】:Creating an Azure Search document schema which enables scoring by filters创建支持按筛选器评分的 Azure 搜索文档架构
【发布时间】:2016-10-12 17:37:44
【问题描述】:

我的域对象是这样的:

 public class MainType { 
     public int Id {get;set;} 
     public string Name {get;set;} 

     public List<TypeA> A_List {get;set;}
     public List<TypeB> B_List {get;set;} 

     ... other properties
}

public class TypeA { 
     public int Id {get;set;} 
     public string Name {get;set;} 

     ... other properties
}

public class TypeAMapping { 
     public int TypeAId {get;set;} 
     public int MainTypeId {get;set;} 
     public int DisplayOrder {get;set;} 
}


public class TypeB { 
     public int Id {get;set;} 
     public string Name {get;set;} 

     ... other properties
}

public class TypeBMapping { 
     public int TypeBId {get;set;} 
     public int MainTypeId {get;set;} 
     public int DisplayOrder {get;set;} 
}

Azure 搜索索引文档不支持复杂类型,因此我需要将这些所有类扁平化为一个模型,如 here 所述。

所以,我创建了一个这样的类:

 public class MainTypeDocumentModel { 
     public int Id {get;set;} 
     public string Name {get;set;} 

     public List<string> A_Id_List {get;set;}
     public List<string> A_Name_List {get;set;}
     public List<string> A_DisplayOrder_List {get;set;}

     public List<string> B_Id_List {get;set;}
     public List<string> B_Name_List {get;set;}
     public List<string> B_DisplayOrder_List {get;set;}

     ... other properties
}

问题是我还需要处理映射类的DisplayOrder 属性。文档未涵盖的内容。

我可以创建查询来搜索由A_Id_List 和/或B_Id_List 过滤的MainTypeDocumentModel。但我需要使用文档的X_DisplayOrder_List 属性中的值对文档进行排序(或得分更高)。

我查看了来自 Microsoft 的 Scoring Profile 文档,但不知道如何针对这种情况实施。

【问题讨论】:

  • 您能否详细说明您要完成的工作?从问题上看不清楚。谢谢!
  • 编辑了问题。谢谢。

标签: azure azure-cognitive-search


【解决方案1】:

听起来您想要的相当于嵌套 A 和 B 上的相关子查询。不幸的是,这目前在 Azure 搜索中是不可能的,因为它需要对复杂类型的内置支持。这是on our radar,但目前没有预计到达时间。

同时,您可以考虑将域类型建模为 Azure 搜索索引的其他方法。一种选择是完全非规范化;有一个 A 索引和一个 B 索引,并为每个与 As 和 Bs 的组合重复 Id 和 Name。另一种选择是完全标准化; MainType、A、B 以及它们之间的关系具有单独的索引,并在客户端进行“连接”。根据您的查询模式和更新频率,需要权衡取舍。 MSDN 论坛上的This thread 更详细地介绍了这些选项。

【讨论】:

  • 性能很重要。所以我需要采用非规范化方法。如果我以这种方式实现,我可以支持方面吗?附言。不久前我投票支持这个问题。
  • 另一个问题:如果我使用非规范化,我将如何在结果中返回唯一 ID?谢谢
  • Azure 搜索的查询通常很便宜(只要没有太多方面),所以如果你没有,我不会对标准化选项的性能做太多假设试了一下,做了一些测量。如果您对数据进行非规范化处理,那么唯一性和构面计数将是一个问题。
  • 我检查了一下。规范化选项已接近我所需要的。我将使过滤器成为客户端,并使用从过滤器获得的 id 请求 MainType。但在这种情况下,将不支持使用过滤器进行文本搜索。
猜你喜欢
  • 1970-01-01
  • 2021-09-02
  • 1970-01-01
  • 2018-03-27
  • 1970-01-01
  • 1970-01-01
  • 2015-07-26
  • 2021-05-11
  • 2021-06-01
相关资源
最近更新 更多