You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/how-to-manage-indexing-policy.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
title: Manage indexing policies in Azure Cosmos DB
3
3
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
5
5
ms.service: cosmos-db
6
6
ms.topic: conceptual
7
-
ms.date: 12/02/2019
8
-
ms.author: thweiss
7
+
ms.date: 04/28/2020
8
+
ms.author: tisande
9
9
---
10
10
11
11
# Manage indexing policies in Azure Cosmos DB
@@ -132,7 +132,7 @@ This indexing policy is equivalent to the one below which manually sets ```kind`
132
132
}
133
133
```
134
134
135
-
> [!NOTE]
135
+
> [!NOTE]
136
136
> 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.
137
137
138
138
### 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`
169
169
170
170
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.
171
171
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
+
172
175
### Composite index defined for (name asc, age desc):
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.
106
+
107
+
Here are some rules for included and excluded paths precedence in Azure Cosmos DB:
108
+
109
+
- Deeper paths are more precise than narrower paths. for example: `/a/b/?` is more precise than `/a/?`.
110
+
111
+
- The `/?` is more precise than `/*`. For example `/a/?` is more precise than `/a/*` so `/a/?` takes precedence.
112
+
113
+
- The path `/*` must be either an included path or excluded path.
114
+
95
115
## Spatial indexes
96
116
97
117
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 +130,8 @@ Azure Cosmos DB, by default, will not create any spatial indexes. If you would l
110
130
111
131
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.
112
132
133
+
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.
134
+
113
135
When defining a composite index, you specify:
114
136
115
137
- Two or more property paths. The sequence in which property paths are defined matters.
0 commit comments