Indexing on nested field in Azure Cosmos DB

做~自己de王妃 提交于 2019-12-11 05:07:47

问题


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

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


回答1:


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
        }

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



来源:https://stackoverflow.com/questions/49049907/indexing-on-nested-field-in-azure-cosmos-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!