本文介绍了在Azure Cosmos DB中的嵌套字段上建立索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Azure Cosmos DB中的文档中的嵌套字段上创建索引.例如.如果我具有以下架构:

I want to create an index on a nested field in a document in Azure Cosmos DB. E.g. if I have the following schema:

{
    'id': 1,
    'nested':
        {
            'mode': 'mode1',
            'text': 'nice text'
        }
}

我想在字段nested.mode上创建索引.该怎么办?

I want to create an index on the field nested.mode. How can this be done?

推荐答案

默认情况下,所有路径都在Cosmos DB中建立索引.要仅对"nested.mode"进行索引,您需要在/nested/mode/?路径上使用适当的数据类型/精度指定索引策略. includedPaths部分中的JSON中的类似内容.

By default, all paths are indexed in Cosmos DB. To index just "nested.mode", you need to specify an indexing policy on the /nested/mode/? path with the appropriate data type/precision. Something like this in JSON within the includedPaths section.

     "path":"/nested/mode/?",
     "indexes":[
        {
           "kind":"Range",
           "dataType":"String",
           "precision":-1
        }

此处有更多详细信息: https://docs.microsoft .com/zh-CN/azure/cosmos-db/indexing-policies .

More details here: https://docs.microsoft.com/en-us/azure/cosmos-db/indexing-policies.

这篇关于在Azure Cosmos DB中的嵌套字段上建立索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 18:50