Azure Search requires documents to be flattened, so what you will need to do is create a query in DocumentDB to help you do this. To get started, there is a document here, that will give you some information on how to model these more complex data types in Azure Search.
Also, I prefer to do this flattening right in DocumentDB. To do this, User Defined Functions (UDF) are a great way to do this. Here is an example that allows you to pass in an Array and take all the items of type "child" and pass it back as an Array.
function convertToArray (data, child) {
var resultArray = [];
for (var i = 0; i < data.length; i++)
{
resultArray.push(data[i][child]);
}
return resultArray;
}
Then within DocumentDB, you would do a query something like this:
SELECT
c.userName,
udf.convertToArray(c.addresses, "city") as City
FROM c
So if c.addresses looked like this:
[
{
"city": "Toronto",
"country": "Canada"
},
{
"city": "Seattle",
"country": "USA"
}
]
The output from the UDF would be:
["Toronto", "Seattle"]
which can then be loaded into the Azure Search in an Collection datatype.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…