我的域名对象如下:
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
属性。哪些文档没有涵盖。
我可以创建查询以搜索MainTypeDocumentModel
和/或A_Id_List
过滤的B_Id_List
。但是我需要使用文档的X_DisplayOrder_List
属性中的值对文档进行排序(或者得分更高)。
我检查了Microsoft的Scoring Profile文档,但无法弄清楚如何实现此方案。
答案 0 :(得分:2)
听起来你想要的是相当于嵌套A和B的相关子查询。不幸的是,Azure搜索目前无法实现这一点,因为它需要内置的复杂类型支持。这是on our radar,但目前没有ETA。
与此同时,您可以考虑将域类型建模为Azure搜索索引的其他方法。一种选择是完全非规范化;有一个A索引和一个B索引,并为As和Bs的每个组合重复Id和Name。另一种选择是完全标准化;为MainType,A,B及它们之间的关系分别设置索引,并在客户端执行“连接”。根据您的查询模式和更新频率,需要进行权衡。 MSDN论坛上的This thread更详细地介绍了这些选项。