Skip to content

Commit a7cc712

Browse files
authored
Update mongodb-indexing.md
1 parent a67fede commit a7cc712

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

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

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ As an alternative, you could create multiple wildcard indexes.
199199

200200
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).
201201

202-
### Unique indexes
202+
###
203+
indexes
203204

204205
[Unique indexes](../unique-keys.md) are useful for enforcing that two or more documents do not contain the same value for indexed fields.
205206

@@ -245,41 +246,6 @@ In the preceding example, omitting the ```"university":1``` clause returns an er
245246
246247
Unique indexes need to be created while the collection is empty.
247248
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-
283249
### TTL indexes
284250
285251
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)