@@ -76,7 +76,7 @@ following changes to perform the schema changes on your MongoDB database:
76
76
specifies the correct database:
77
77
78
78
- Make sure your ``connections`` array item contains a valid ``mongodb``
79
- entry in your ``config/database.php`` file
79
+ entry in your ``config/database.php`` file
80
80
- Specify ``"mongodb"`` in the ``$connection`` field of your migration class
81
81
82
82
The following example migration class contains the following methods:
@@ -175,30 +175,30 @@ the migration, including the default index on the ``_id`` field:
175
175
.. io-code-block::
176
176
177
177
.. input:: /includes/schema-builder/flights_migration.php
178
- :language: php
179
- :dedent:
180
- :start-after: begin create index
181
- :end-before: end create index
178
+ :language: php
179
+ :dedent:
180
+ :start-after: begin create index
181
+ :end-before: end create index
182
182
183
183
.. output::
184
- :language: json
185
- :visible: false
186
-
187
- [
188
- { v: 2, key: { _id: 1 }, name: '_id_' },
189
- { v: 2, key: { mission_type: 1 }, name: 'mission_type_1' },
190
- {
191
- v: 2,
192
- key: { launch_location: 1, launch_date: -1 },
193
- name: 'launch_location_1_launch_date_-1'
194
- },
195
- {
196
- v: 2,
197
- key: { mission_id: 1 },
198
- name: 'unique_mission_id_idx',
199
- unique: true
200
- }
201
- ]
184
+ :language: json
185
+ :visible: false
186
+
187
+ [
188
+ { v: 2, key: { _id: 1 }, name: '_id_' },
189
+ { v: 2, key: { mission_type: 1 }, name: 'mission_type_1' },
190
+ {
191
+ v: 2,
192
+ key: { launch_location: 1, launch_date: -1 },
193
+ name: 'launch_location_1_launch_date_-1'
194
+ },
195
+ {
196
+ v: 2,
197
+ key: { mission_id: 1 },
198
+ name: 'unique_mission_id_idx',
199
+ unique: true
200
+ }
201
+ ]
202
202
203
203
Specify Index Options
204
204
~~~~~~~~~~~~~~~~~~~~~
@@ -215,35 +215,35 @@ field:
215
215
.. io-code-block::
216
216
217
217
.. input:: /includes/schema-builder/passengers_migration.php
218
- :language: php
219
- :dedent:
220
- :start-after: begin index options
221
- :end-before: end index options
218
+ :language: php
219
+ :dedent:
220
+ :start-after: begin index options
221
+ :end-before: end index options
222
222
223
223
.. output::
224
- :language: json
225
- :visible: false
226
-
227
- [
228
- { v: 2, key: { _id: 1 }, name: '_id_' },
229
- {
230
- v: 2,
231
- key: { last_name: 1 },
232
- name: 'passengers_collation_idx',
233
- collation: {
234
- locale: 'de@collation=phonebook',
235
- caseLevel: false,
236
- caseFirst: 'off',
237
- strength: 3,
238
- numericOrdering: true,
239
- alternate: 'non-ignorable',
240
- maxVariable: 'punct',
241
- normalization: false,
242
- backwards: false,
243
- version: '57.1'
244
- }
245
- }
246
- ]
224
+ :language: json
225
+ :visible: false
226
+
227
+ [
228
+ { v: 2, key: { _id: 1 }, name: '_id_' },
229
+ {
230
+ v: 2,
231
+ key: { last_name: 1 },
232
+ name: 'passengers_collation_idx',
233
+ collation: {
234
+ locale: 'de@collation=phonebook',
235
+ caseLevel: false,
236
+ caseFirst: 'off',
237
+ strength: 3,
238
+ numericOrdering: true,
239
+ alternate: 'non-ignorable',
240
+ maxVariable: 'punct',
241
+ normalization: false,
242
+ backwards: false,
243
+ version: '57.1'
244
+ }
245
+ }
246
+ ]
247
247
248
248
To learn more about index options, see :manual:`Options for All Index Types </reference/method/db.collection.createIndex/#options-for-all-index-types>`
249
249
in the {+server-docs-name+}.
@@ -276,25 +276,25 @@ the ``_id`` field:
276
276
.. io-code-block::
277
277
278
278
.. input:: /includes/schema-builder/planets_migration.php
279
- :language: php
280
- :dedent:
281
- :start-after: begin index helpers
282
- :end-before: end index helpers
279
+ :language: php
280
+ :dedent:
281
+ :start-after: begin index helpers
282
+ :end-before: end index helpers
283
283
284
284
.. output::
285
- :language: json
286
- :visible: false
287
-
288
- [
289
- { v: 2, key: { _id: 1 }, name: '_id_' },
290
- { v: 2, key: { rings: 1 }, name: 'rings_1', sparse: true },
291
- {
292
- v: 2,
293
- key: { last_visible_dt: 1 },
294
- name: 'last_visible_dt_1',
295
- expireAfterSeconds: 86400
296
- }
297
- ]
285
+ :language: json
286
+ :visible: false
287
+
288
+ [
289
+ { v: 2, key: { _id: 1 }, name: '_id_' },
290
+ { v: 2, key: { rings: 1 }, name: 'rings_1', sparse: true },
291
+ {
292
+ v: 2,
293
+ key: { last_visible_dt: 1 },
294
+ name: 'last_visible_dt_1',
295
+ expireAfterSeconds: 86400
296
+ }
297
+ ]
298
298
299
299
You can specify sparse, TTL, and unique indexes on either a single field or
300
300
compound index by specifying them in the index options.
@@ -307,26 +307,26 @@ field:
307
307
.. io-code-block::
308
308
309
309
.. input:: /includes/schema-builder/planets_migration.php
310
- :language: php
311
- :dedent:
312
- :start-after: begin multi index helpers
313
- :end-before: end multi index helpers
310
+ :language: php
311
+ :dedent:
312
+ :start-after: begin multi index helpers
313
+ :end-before: end multi index helpers
314
314
315
315
.. output::
316
- :language: json
317
- :visible: false
318
-
319
- [
320
- { v: 2, key: { _id: 1 }, name: '_id_' },
321
- {
322
- v: 2,
323
- key: { last_visible_dt: 1 },
324
- name: 'last_visible_dt_1',
325
- unique: true,
326
- sparse: true,
327
- expireAfterSeconds: 3600
328
- }
329
- ]
316
+ :language: json
317
+ :visible: false
318
+
319
+ [
320
+ { v: 2, key: { _id: 1 }, name: '_id_' },
321
+ {
322
+ v: 2,
323
+ key: { last_visible_dt: 1 },
324
+ name: 'last_visible_dt_1',
325
+ unique: true,
326
+ sparse: true,
327
+ expireAfterSeconds: 3600
328
+ }
329
+ ]
330
330
331
331
To learn more about these indexes, see :manual:`Index Properties </core/indexes/index-properties/>`
332
332
in the {+server-docs-name+}.
@@ -351,25 +351,25 @@ default index on the ``_id`` field:
351
351
352
352
.. io-code-block::
353
353
.. input:: /includes/schema-builder/spaceports_migration.php
354
- :language: php
355
- :dedent:
356
- :start-after: begin create geospatial index
357
- :end-before: end create geospatial index
354
+ :language: php
355
+ :dedent:
356
+ :start-after: begin create geospatial index
357
+ :end-before: end create geospatial index
358
358
359
359
.. output::
360
- :language: json
361
- :visible: false
360
+ :language: json
361
+ :visible: false
362
362
363
- [
364
- { v: 2, key: { _id: 1 }, name: '_id_' },
365
- {
366
- v: 2,
367
- key: { launchpad_location: '2dsphere' },
368
- name: 'launchpad_location_2dsphere',
369
- '2dsphereIndexVersion': 3
370
- },
371
- { v: 2, key: { runway_location: '2d' }, name: 'runway_location_2d' }
372
- ]
363
+ [
364
+ { v: 2, key: { _id: 1 }, name: '_id_' },
365
+ {
366
+ v: 2,
367
+ key: { launchpad_location: '2dsphere' },
368
+ name: 'launchpad_location_2dsphere',
369
+ '2dsphereIndexVersion': 3
370
+ },
371
+ { v: 2, key: { runway_location: '2d' }, name: 'runway_location_2d' }
372
+ ]
373
373
374
374
375
375
To learn more about geospatial indexes, see
@@ -439,43 +439,43 @@ indexes created by running the migration:
439
439
.. io-code-block::
440
440
441
441
.. input:: /includes/schema-builder/galaxies_migration.php
442
- :language: php
443
- :dedent:
444
- :start-after: begin-create-search-indexes
445
- :end-before: end-create-search-indexes
442
+ :language: php
443
+ :dedent:
444
+ :start-after: begin-create-search-indexes
445
+ :end-before: end-create-search-indexes
446
446
447
447
.. output::
448
- :language: json
449
- :visible: false
450
-
451
- {
452
- "id": "...",
453
- "name": "dynamic_index",
454
- "type": "search",
455
- "status": "READY",
456
- "queryable": true,
457
- "latestDefinition": {
458
- "mappings": { "dynamic": true }
459
- },
460
- ...
461
- }
462
- {
463
- "id": "...",
464
- "name": "auto_index",
465
- "type": "search",
466
- "status": "READY",
467
- "queryable": true,
468
- "latestDefinition": {
469
- "mappings": {
470
- "fields": { "name": [
471
- { "type": "string", "analyzer": "lucene.english" },
472
- { "type": "autocomplete", "analyzer": "lucene.english" },
473
- { "type": "token" }
474
- ] }
475
- }
476
- },
477
- ...
478
- }
448
+ :language: json
449
+ :visible: false
450
+
451
+ {
452
+ "id": "...",
453
+ "name": "dynamic_index",
454
+ "type": "search",
455
+ "status": "READY",
456
+ "queryable": true,
457
+ "latestDefinition": {
458
+ "mappings": { "dynamic": true }
459
+ },
460
+ ...
461
+ }
462
+ {
463
+ "id": "...",
464
+ "name": "auto_index",
465
+ "type": "search",
466
+ "status": "READY",
467
+ "queryable": true,
468
+ "latestDefinition": {
469
+ "mappings": {
470
+ "fields": { "name": [
471
+ { "type": "string", "analyzer": "lucene.english" },
472
+ { "type": "autocomplete", "analyzer": "lucene.english" },
473
+ { "type": "token" }
474
+ ] }
475
+ }
476
+ },
477
+ ...
478
+ }
479
479
480
480
Vector Search
481
481
`````````````
@@ -495,31 +495,31 @@ indexes created by running the migration:
495
495
496
496
.. io-code-block::
497
497
.. input:: /includes/schema-builder/galaxies_migration.php
498
- :language: php
499
- :dedent:
500
- :start-after: begin-create-vs-index
501
- :end-before: end-create-vs-index
498
+ :language: php
499
+ :dedent:
500
+ :start-after: begin-create-vs-index
501
+ :end-before: end-create-vs-index
502
502
503
503
.. output::
504
- :language: json
505
- :visible: false
506
-
507
- {
508
- "id": "...",
509
- "name": "vs_index",
510
- "type": "vectorSearch",
511
- "status": "READY",
512
- "queryable": true,
513
- "latestDefinition": {
514
- "fields": [ {
515
- "type": "vector",
516
- "numDimensions": 4,
517
- "path": "vector4",
518
- "similarity": "cosine"
519
- } ]
520
- },
521
- ...
522
- }
504
+ :language: json
505
+ :visible: false
506
+
507
+ {
508
+ "id": "...",
509
+ "name": "vs_index",
510
+ "type": "vectorSearch",
511
+ "status": "READY",
512
+ "queryable": true,
513
+ "latestDefinition": {
514
+ "fields": [ {
515
+ "type": "vector",
516
+ "numDimensions": 4,
517
+ "path": "vector4",
518
+ "similarity": "cosine"
519
+ } ]
520
+ },
521
+ ...
522
+ }
523
523
524
524
Drop a Search Index
525
525
```````````````````
0 commit comments