Skip to content

Commit 4378900

Browse files
authored
Merge pull request #207258 from gahl-levy/patch-30
Update mongodb-indexing.md
2 parents 1bd57d1 + 1d0c286 commit 4378900

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

articles/cosmos-db/mongodb/mongodb-indexing.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -245,41 +245,6 @@ In the preceding example, omitting the ```"university":1``` clause returns an er
245245
246246
Unique indexes need to be created while the collection is empty.
247247
248-
Support for unique index on existing collections with data is available in preview for accounts that do not use Synapse Link or Continuous backup. You can sign up for the feature “Azure Cosmos DB API for MongoDB New Unique Indexes in 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 }`:
268-
269-
```shell
270-
db.books.createIndex(
271-
{ title: 1 },
272-
{ unique: true, partialFilterExpression: { rating: { $gte: 3 } } }
273-
)
274-
```
275-
276-
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-
283248
### TTL indexes
284249
285250
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

Comments
 (0)