首页 > 解决方案 > Cosmos 中可选字段的复合索引

问题描述

我在 Cosmos DB 中有一个集合,其中包含不同类型(和模式)的文档:

{
"partKey": "...",
"type": "type1",
"data": {
    "field1": 123,
    "field2": "sdfsdf"
  }
}
{
"partKey": "...",
"type": "type2",
"data": {
    "field3": ["123", "456", "789"]
  }
}

我正在尝试创建一个复合索引[/type, /data/field3/[]/?],但遇到了一个问题:

The indexing path '\\/data\\/field3\\/[]\\/?' could not be accepted, failed near position '15'. Please ensure that the path is a valid path. Common errors include invalid characters or absence of quotes around labels

标签: azure-cosmosdbcomposite-index

解决方案


Cosmos DB 中的复合索引不支持通配符。这是一个综合指数样本作为参考。

我们将更新我们的文档以使其更加清晰。我查看了这些,我们今天没有记录。

谢谢。


推荐阅读