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/mongodb/how-to-configure-capabilities.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.reviewer: gahllevy
7
7
ms.service: cosmos-db
8
8
ms.subservice: mongodb
9
9
ms.topic: how-to
10
-
ms.date: 10/12/2022
10
+
ms.date: 10/24/2022
11
11
ms.custom: ignite-2022
12
12
---
13
13
@@ -31,6 +31,8 @@ Capabilities are features that can be added or removed to your API for MongoDB a
31
31
|`EnableMongoRoleBasedAccessControl`| Enable support for creating Users/Roles for native MongoDB role-based access control | No |
32
32
|`EnableMongoRetryableWrites`| Enables support for retryable writes on the account | Yes |
33
33
|`EnableMongo16MBDocumentSupport`| Enables support for inserting documents upto 16 MB in size | No |
34
+
|`EnableUniqueCompoundNestedDocs`| Enables support for compound and unique indexes on nested fields, as long as the nested field is not an array. | No |
@@ -52,9 +52,22 @@ In the API for MongoDB, compound indexes are **required** if your query needs th
52
52
53
53
A compound index or single field indexes for each field in the compound index will result in the same performance for filtering in queries.
54
54
55
+
Compounded indexes on nested fields are not supported by default due to limiations with arrays. If your nested field does not contain an array, the index will work as intended. If your nested field contains an array (anywhere on the path), that value will be ignored in the index.
56
+
57
+
For example a compound index containing people.tom.age will work in this case since there's no array on the path:
This feature can be enabled for your database account by [enabling the 'EnableUniqueCompoundNestedDocs' capability](how-to-configure-capabilities.md).
67
+
55
68
56
69
> [!NOTE]
57
-
> You can't create compound indexes on nested properties or arrays.
70
+
> You can't create compound indexes on arrays.
58
71
59
72
The following command creates a compound index on the fields `name` and `age`:
60
73
@@ -245,6 +258,20 @@ In the preceding example, omitting the ```"university":1``` clause returns an er
245
258
246
259
Unique indexes need to be created while the collection is empty.
247
260
261
+
Unique indexes on nested fields are not supported by default due to limiations with arrays. If your nested field does not contain an array, the index will work as intended. If your nested field contains an array (anywhere on the path), that value will be ignored in the unique index and uniqueness wil not be preserved for that value.
262
+
263
+
For example a unique index on people.tom.age will work in this case since there's no array on the path:
This feature can be enabled for your database account by [enabling the 'EnableUniqueCompoundNestedDocs' capability](how-to-configure-capabilities.md).
273
+
274
+
248
275
### TTL indexes
249
276
250
277
To enable document expiration in a particular collection, you need to create a [time-to-live (TTL) index](../time-to-live.md). A TTL index is an index on the `_ts` field with an `expireAfterSeconds` value.
0 commit comments