2
votes

My domain objects are like:

 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 index documents does not support for complex types so I need to flatten these all classes into a model as described here.

So, I created a class like this one:

 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
}

The problem is I also need to process DisplayOrder property of the mapping classes. Which the documentation does not cover.

I can create queries to search MainTypeDocumentModel filtered by A_Id_List and/or B_Id_List. But I need to sort the documents (or score higher) with the values in X_DisplayOrder_List property of the documents.

I checked the Scoring Profile docs from Microsoft but couldn't figure out how to implement for this scenario.

1
Could you please elaborate a bit on what you're trying to accomplish? It's not clear from the question. Thanks! - Bruce Johnston
Edited the question. Thanks. - Kerem Demirer

1 Answers

2
votes

It sounds like what you want is the equivalent of correlated sub-queries on the nested A's and B's. Unfortunately this is not currently possible in Azure Search since it requires built-in support for complex types. This is on our radar but there is no ETA at this time.

In the meantime, you can consider other ways of modeling your domain types as Azure Search indexes. One option is full denormalization; Have an A index and a B index, and repeat Id and Name for each combination with As and Bs. Another option is full normalization; Have separate indexes for MainType, A, B, and the relations between them, and do the "joins" on the client side. There are tradeoffs involved depending on your query patterns and update frequency. This thread on the MSDN forums covers these options in a bit more detail.