Skip to content

Commit 84652ce

Browse files
committed
indexing docs wildcard/? path updates
1 parent 50ba02a commit 84652ce

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

articles/cosmos-db/how-to-manage-indexing-policy.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Manage indexing policies in Azure Cosmos DB
33
description: Learn how to manage indexing policies, include or exclude a property from indexing, how to define indexing using different Azure Cosmos DB SDKs
4-
author: ThomasWeiss
4+
author: timsander1
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 12/02/2019
8-
ms.author: thweiss
7+
ms.date: 04/28/2020
8+
ms.author: tisande
99
---
1010

1111
# Manage indexing policies in Azure Cosmos DB
@@ -132,7 +132,7 @@ This indexing policy is equivalent to the one below which manually sets ```kind`
132132
}
133133
```
134134

135-
> [!NOTE]
135+
> [!NOTE]
136136
> It is generally recommended to use an **opt-out** indexing policy to let Azure Cosmos DB proactively index any new property that may be added to your model.
137137
138138
### Using a spatial index on a specific property path only
@@ -169,6 +169,9 @@ This indexing policy is equivalent to the one below which manually sets ```kind`
169169

170170
In addition to including or excluding paths for individual properties, you can also specify a composite index. If you would like to perform a query that has an `ORDER BY` clause for multiple properties, a [composite index](index-policy.md#composite-indexes) on those properties is required. Additionally, composite indexes will have a performance benefit for queries that have a filter and have an ORDER BY clause on different properties.
171171

172+
> [!NOTE]
173+
> Composite paths have an implicit `/?` since only the scalar value at that path is indexed. The `/*` wildcard is not supported in composite paths. You shouldn't specify `/?` or `/*` in a composite path.
174+
172175
### Composite index defined for (name asc, age desc):
173176

174177
```json

articles/cosmos-db/index-policy.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to configure and change the default indexing policy for
44
author: timsander1
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 03/26/2020
7+
ms.date: 04/28/2020
88
ms.author: tisande
99
---
1010

@@ -92,6 +92,25 @@ When not specified, these properties will have the following default values:
9292

9393
See [this section](how-to-manage-indexing-policy.md#indexing-policy-examples) for indexing policy examples for including and excluding paths.
9494

95+
## Include/exclude precedence
96+
97+
If your included paths and excluded paths have a conflict, the deeper path takes precedence.
98+
99+
Here's an example:
100+
101+
**Included Path**: `/food/ingredients/nutrition/*`
102+
**Excluded Path**: `/food/ingredients/*`
103+
104+
In this case, the included path takes precedence over the excluded path because it is more precise. Based on these paths, any data in the `food/ingredients` path or nested within would be excluded from the index. The exception would be data within the included path: `/food/ingredients/nutrition/*`, which would be indexed.
105+
106+
Here are some rules for included and excluded paths precedence in Azure Cosmos DB:
107+
108+
- Deeper paths are more precise than narrower paths. for example: `/a/b/?` is more precise than `/a/?`.
109+
110+
- The `/?` is more precise than `/*`. For example `/a/?` is more precise than `/a/*` so `/a/?` takes precedence.
111+
112+
- The path `/*` must be either an included path or excluded path.
113+
95114
## Spatial indexes
96115

97116
When you define a spatial path in the indexing policy, you should define which index ```type``` should be applied to that path. Possible types for spatial indexes include:
@@ -110,6 +129,8 @@ Azure Cosmos DB, by default, will not create any spatial indexes. If you would l
110129

111130
Queries that have an `ORDER BY` clause with two or more properties require a composite index. You can also define a composite index to improve the performance of many equality and range queries. By default, no composite indexes are defined so you should [add composite indexes](how-to-manage-indexing-policy.md#composite-indexing-policy-examples) as needed.
112131

132+
Unlike with included or excluded paths, you can't create a path with the `/*` wildcard. Every composite path has an implicit `/?` at the end of the path that you don't need to specify. Composite paths lead to a scalar value and this is the only value that is included in the composite index.
133+
113134
When defining a composite index, you specify:
114135

115136
- Two or more property paths. The sequence in which property paths are defined matters.

0 commit comments

Comments
 (0)