创建Azure Search文档模式,支持按过滤器评分



我的域对象是这样的:

 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 Search索引文档不支持复杂类型,所以我需要将所有这些类扁平化到这里所描述的模型中。

所以,我创建了一个像这样的类:
 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属性中的值对文档(或得分更高)进行排序。

我检查了微软的评分配置文件,但不知道如何实现这个场景。

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

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

最新更新