多级文档搜索支持什么模型? [英] what is the supported Model for multi-level Document search?

查看:70
本文介绍了多级文档搜索支持什么模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在DocumentDb中创建了很少的文档,我正在寻找如何搜索多级或 使用Azure搜索服务在单个文档中创建父子对象.

I have created few documents in DocumentDb and i am looking for how to search multi-level or parent child objects in single document using Azure search services.

您能帮我一个忙/任何链接吗?

can you any one help me out/any links.

推荐答案

Azure搜索需要将文档弄平,因此您需要做的是在DocumentDB中创建一个查询来帮助您做到这一点.首先,这里有文档,它将为您提供有关如何在Azure搜索中为这些更复杂的数据类型建模的信息.

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.

此外,我更喜欢在DocumentDB中进行此拼合.为此,用户定义函数(UDF)是执行此操作的好方法.这是一个示例,允许您传入一个数组,并接受所有"child"类型的项目,然后将其作为一个数组传回.

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;
}

然后在DocumentDB中,您将执行如下查询:

Then within DocumentDB, you would do a query something like this:

SELECT 
c.userName, 
udf.convertToArray(c.addresses, "city") as City
FROM c

所以,如果c.addresses看起来像这样:

So if c.addresses looked like this:

[
    {
      "city": "Toronto",
      "country": "Canada"
    },
    {
      "city": "Seattle",
      "country": "USA"
    }
  ]

UDF的输出为:

["Toronto", "Seattle"]

然后可以将其以Collection数据类型加载到Azure搜索中.

which can then be loaded into the Azure Search in an Collection datatype.

这篇关于多级文档搜索支持什么模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆