在 Cosmos DB 中设置索引路径

huangapple go评论56阅读模式
英文:

Index setting path in Cosmos DB

问题

    "includedPaths": [
        {
            "path": "/PartitionKey/*"
        }
    ]

如果我将Path仅更改为"/PartitionKey",那会有什么不同?


<details>
<summary>英文:</summary>

In Cosmos DB, I have an index setting that looks like this:
```json
    &quot;includedPaths&quot;: [
        {
            &quot;path&quot;: &quot;/PartitionKey/*&quot;
        }
    ]

What would be the difference if I changed the Path to only this: "/PartitionKey"?

答案1

得分: 2

这意味着在文档中嵌套节点上将不会启用索引。任何位于 /PartitionKey/ 下的内容。如果您计划查询此路径的属性的子属性,则应使用字符 *。

来自文档

> /* 通配符可用于匹配节点下面的任何元素

如果您没有嵌套节点,那么这就足够了。此外,您需要在索引路径的末尾使用 ? 字符,以便为查询提供服务,这些查询会在此属性上进行查询。

/PartitionKey/?
英文:

That means indexing won't be enabled on the nested nodes in the document. The path to anything under /PartitionKey/. The character * should be used if you are planing to query on sub properties of the property for this path.

from the documentation,

> the /* wildcard can be used to match any elements below the node

If you don't have nested nodes then this should be good enough. Also you need to use the ? character at the end of the index path is required to serve queries that query on this property.

/PartitionKey/?

huangapple
  • 本文由 发表于 2023年2月18日 20:24:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75493319.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定