问题
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