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/mongodb-indexing.md
+2-36Lines changed: 2 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,7 +199,8 @@ As an alternative, you could create multiple wildcard indexes.
199
199
200
200
The following operations are common for accounts serving wire protocol version 4.0 and accounts serving earlier versions. You can learn more about [supported indexes and indexed properties](feature-support-40.md#indexes-and-index-properties).
201
201
202
-
### Unique indexes
202
+
###
203
+
indexes
203
204
204
205
[Unique indexes](../unique-keys.md) are useful for enforcing that two or more documents do not contain the same value for indexed fields.
205
206
@@ -245,41 +246,6 @@ In the preceding example, omitting the ```"university":1``` clause returns an er
245
246
246
247
Unique indexes need to be created while the collection is empty.
247
248
248
-
Support forunique index on existing collections with data is availablein preview foraccounts that do not use Synapse Link or Continuous backup. You can sign up for the feature “Azure Cosmos DB API for MongoDB New Unique Indexesin existing collection” through the [Preview Features blade in the portal](./../access-previews.md).
249
-
250
-
#### Unique partial indexes
251
-
252
-
Unique partial indexes can be created by specifying a partialFilterExpression along with the 'unique' constraint in the index. This results in the unique constraint being applied only to the documents that meet the specified filter expression.
253
-
254
-
The unique constraint will not be effective for documents that do not meet the specified criteria. As a result, other documents will not be prevented from being inserted into the collection.
255
-
256
-
This feature is supported with the Cosmos DB API for MongoDB versions 3.6 and above.
257
-
258
-
To create a unique partial index from Mongo Shell, use the command`db.collection.createIndex()` with the 'partialFilterExpression' option and 'unique' constraint.
259
-
The partialFilterExpression option accepts a json document that specifies the filter condition using:
260
-
261
-
* equality expressions (i.e. field: value or using the $eq operator),
262
-
*'$exists: true' expression,
263
-
*$gt, $gte, $lt, $lte expressions,
264
-
*$type expressions,
265
-
*$and operator at the top-level only
266
-
267
-
The following command creates an index on collection `books` that specifies a unique constraint on the `title` field and a partial filter expression `rating: { $gte: 3 }`:
To delete a partial unique index using from Mongo Shell, use the command`getIndexes()` to list the indexes in the collection.
277
-
Then drop the index with the following command:
278
-
279
-
```shell
280
-
db.books.dropIndex("indexName")
281
-
```
282
-
283
249
### TTL indexes
284
250
285
251
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