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/vcore/how-to-create-indexes.md
+9-4Lines changed: 9 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Indexing Best Practices in Azure Cosmos DB for MongoDB vCore
3
3
titleSuffix: Azure Cosmos DB for MongoDB vCore
4
4
description: Use create Indexing for empty collections in Azure Cosmos DB for MongoDB vCore.
5
5
author: abinav2307
6
-
ms.author: abrameesh
6
+
ms.author: abramees
7
7
ms.reviewer: sidandrews
8
8
ms.service: cosmos-db
9
9
ms.subservice: mongodb-vcore
@@ -46,9 +46,14 @@ If the createIndex commands are being issued through the Mongo Shell, use Ctrl +
46
46
Using Ctrl + C to interrupt the createIndex command after it has been issued does not terminate the index build operation on the server. It simply stops the Shell from waiting on a response from the server, while the server asynchronously continues to build the index over the existing documents.
47
47
48
48
## Create Compound Indexes for queries with predicates on multiple fields
49
-
Compound indexes should be used for the following scenarios:
50
-
- Queries with filters on multiple fields
51
-
- Queries with filters on multiple fields and with one or more fields sorted in ascending or descending order
49
+
Compound indexes should be used in the following scenarios:
50
+
- Queries with filters on any field in the JSON structure making it easier to use wildcard indexing instead of indexing each field individually.
51
+
- Queries with filters on all but a few fields making it is easier to exclude a few fields instead of indexing most of the fields individually.
52
+
53
+
Wildcard indexing will soon be available in Azure Cosmos DB for MongoDB vCore. Until then, this sample provides a workaround to circumvent creating individual indexes. The solution takes a sample json file and performs the following actions:
54
+
- Iterates through each root level field and creates an index on the field.
55
+
- Iterates through each nested field and creates an index in the field after concatenating the path to the nested field.
56
+
- Handles Objects, Arrays and base field types accordingly
52
57
53
58
Consider the following document within the 'cosmicworks' database and 'employee' collection
0 commit comments