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
-35Lines changed: 0 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,41 +245,6 @@ In the preceding example, omitting the ```"university":1``` clause returns an er
245
245
246
246
Unique indexes need to be created while the collection is empty.
247
247
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
248
### TTL indexes
284
249
285
250
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