Skip to content

Commit 54fe788

Browse files
committed
fixing the TOC
1 parent 852e258 commit 54fe788

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

articles/cosmos-db/mongodb/vcore/TOC.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
href: how-to-create-wildcard-indexes.md
8989
- name: Search and query text
9090
href: how-to-create-text-index.md
91+
- name: Optimize index creation
92+
href: how-to-create-indexes.md
9193
- name: Scale cluster
9294
href: how-to-scale-cluster.md
9395
- name: Restore cluster
@@ -98,10 +100,6 @@
98100
href: how-to-monitor-diagnostics-logs.md
99101
- name: Use Azure Private Link
100102
href: how-to-private-link.md
101-
- name: Optimize index creation
102-
href: how-to-create-indexes.md
103-
- name: Create wildcard indexes
104-
href: how-to-create-wildcard-indexes.md
105103
- name: Reference
106104
items:
107105
- name: Release notes

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

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This example application stores articles as documents with the following structu
4141
}
4242
```
4343

44-
### Single field indexes
44+
## Single field indexes
4545

4646
Single field indexes store information from a single field in a collection. The sort order of the single field index doesn't matter. _id field remains indexed by default.
4747

@@ -54,31 +54,37 @@ MongoDB vcore supports creating index at following
5454
The following command creates a single field index on the field `author` and the following command creates it on an embedded field `firstName`.
5555

5656
```javascript
57-
db.coll.createIndex({"author": 1})
57+
use cosmicworks
58+
59+
db.products.createIndex({"author": 1})
5860

5961
// indexing embedded property
60-
db.coll.createIndex({"author.firstName": -1})
62+
db.products.createIndex({"author.firstName": -1})
6163
```
6264

6365
One query can use multiple single field indexes where available.
6466

6567
> [!NOTE]
6668
> Azure Cosmos DB for MongoDB vcore allows creating maximum of 64 indexes on a collection.
6769
68-
### Compound indexes
70+
## Compound indexes
6971

7072
Compound indexes are required if your query needs the ability to **query or sort** data from two or more fields in each document in a collection.
7173

7274
The following command creates a compound index on the fields `author` and `launchDate` in opposite sort order.
7375

7476
```javascript
75-
db.coll.createIndex({"author":1, "launchDate":-1})
77+
use cosmicworks
78+
79+
db.products.createIndex({"author":1, "launchDate":-1})
7680
```
7781

7882
`Order` of columns affect the selectivity or utilization of index. The `find` query wouldn't utilize the index created.
7983

8084
```javascript
81-
db.coll.find({"launchDate": {$gt: ISODate("2024-06-01T00:00:00.000Z")}})
85+
use cosmicworks
86+
87+
db.products.find({"launchDate": {$gt: ISODate("2024-06-01T00:00:00.000Z")}})
8288
```
8389

8490
Compounded indexes on nested fields aren't supported by default due to limitations with arrays. If your nested field doesn't contain an array, the index works as intended. If your nested field contains an array (anywhere on the path), that value is ignored in the index.
@@ -112,12 +118,14 @@ Compound index provides support for
112118
- Maximum of 32 columns within a compound index.
113119
- Indexing nested properties.
114120

115-
### Partial indexes
121+
## Partial indexes
116122

117123
Indexes that have an associated query filter that describes when to generate a term in the index.
118124

119125
```javascript
120-
db.coll.createIndex (
126+
use cosmicworks
127+
128+
db.products.createIndex (
121129
{ "author": 1, "launchDate": 1 },
122130
{ partialFilterExpression: { "launchDate": { $gt: ISODate("2024-06-24T10:08:20.000Z") } } }
123131
)
@@ -127,7 +135,7 @@ db.coll.createIndex (
127135

128136
- Partial indexes don't support `ORDER BY` or `UNIQUE` unless the filter qualifies.
129137

130-
### Text indexes
138+
## Text indexes
131139

132140
Text indexes are special data structures that optimize text-based queries, making them faster and more efficient.
133141

@@ -142,13 +150,15 @@ db.products.createIndex({ title: "text" })
142150
> [!NOTE]
143151
> While you can define only one text index per collection, Azure Cosmos DB for MongoDB vCore allows you to create text indexes on combination of multiple fields to enable you to perform text searches across different fields in your documents.
144152
145-
#### Configure text index options
153+
### Configure text index options
146154

147155
Text indexes in Azure Cosmos DB for MongoDB vcore come with several options to customize their behavior. For example, you can specify the language for text analysis, set weights to prioritize certain fields, and configure case-insensitive searches. Here's an example of creating a text index with options:
148156

149157
- Create an index to support search on both the `title` and `content` fields with English language support. Also, assign higher weights to the `title` field to prioritize it in search results.
150158

151159
```javascript
160+
use cosmicworks
161+
152162
db.products.createIndex(
153163
{ title: "text", content: "text" },
154164
{ default_language: "english", weights: { title: 10, content: 5 }, caseSensitive: false }
@@ -158,13 +168,15 @@ db.products.createIndex(
158168
> [!NOTE]
159169
> When a client performs a text search query with the term "Cosmos DB," the score for each document in the collection will be calculated based on the presence and frequency of the term in both the "title" and "content" fields, with higher importance given to the "title" field due to its higher weight.
160170
161-
#### Perform a text search using a text index
171+
### Perform a text search using a text index
162172

163173
Once the text index is created, you can perform text searches using the "text" operator in your queries. The text operator takes a search string and matches it against the text index to find relevant documents.
164174

165175
- Perform a text search for the phrase `Cosmos DB`.
166176

167177
```javascript
178+
use cosmicworks
179+
168180
db.products.find(
169181
{ $text: { $search: "Cosmos DB" } }
170182
)
@@ -173,6 +185,8 @@ db.products.find(
173185
- Optionally, use the `$meta` projection operator along with the `textScore` field in a query to see the weight
174186

175187
```javascript
188+
use cosmicworks
189+
176190
db.products.find(
177191
{ $text: { $search: "Cosmos DB" } },
178192
{ score: { $meta: "textScore" } }
@@ -187,16 +201,18 @@ db.products.find(
187201
- Hint() isn't supported in combination with a query using $text expression.
188202
- Text indexes can be relatively large, consuming significant storage space compared to other index types.
189203

190-
### WildCard indexes
204+
## WildCard indexes
191205

192206
Index on single field, indexes all paths beneath the `field` , excluding other fields that are on the same level. For example, for the following sample document
193207

194-
```javascript
195-
"children":
208+
```json
209+
{
210+
"children":
196211
{
197212
"familyName": "Merriam",
198213
"pets": { "details": {“name”: "Goofy", ”age”: 3} }
199214
}
215+
}
200216
```
201217

202218
Creating an index on { "pets.$**": 1 }, creates index on details & sub-document properties but doesn't create an index on “familyName”.
@@ -208,7 +224,7 @@ Creating an index on { "pets.$**": 1 }, creates index on details & sub-document
208224
- A compound wildcard index can only have 1 wildcard term and 1 or more additional index terms.
209225
`{ "pets.$**": 1, “familyName”: 1 }`
210226

211-
### Geospatial indexes
227+
## Geospatial indexes
212228

213229
Geospatial indexes support queries on data stored as GeoJSON objects or legacy coordinate pairs. You can use geospatial indexes to improve performance for queries on geospatial data or to run certain geospatial queries.
214230

@@ -217,7 +233,7 @@ Azure Cosmos DB for MongoDB vcore provides two types of geospatial indexes:
217233
- 2dsphere Indexes, which support queries that interpret geometry on a sphere.
218234
- 2d Indexes, which support queries that interpret geometry on a flat surface.
219235

220-
#### 2d indexes
236+
### 2d indexes
221237

222238
2d indexes are supported only with legacy coordinate pair style of storing geospatial data.
223239

@@ -232,7 +248,7 @@ db.places.createIndex({ "location": "2d"});
232248
- Only 1 location field can be part of the `2d` index and only 1 other non-geospatial field can be part of the `compound 2d` index
233249
`db.places.createIndex({ "location": "2d", "non-geospatial-field": 1 / -1 })`
234250

235-
#### 2dsphere indexes
251+
### 2dsphere indexes
236252

237253
`2dsphere` indexes support geospatial queries on an earth-like sphere. It can support both GeoJSON objects or legacy coordinate pairs. `2dSphere` indexes work with the GeoJSON style of storing data, if legacy points are encountered then these are converted to GeoJSON point.
238254

0 commit comments

Comments
 (0)