@@ -157,10 +157,15 @@ drop various types of indexes on a collection.
157
157
Create an Index
158
158
~~~~~~~~~~~~~~~
159
159
160
- To create indexes, call the ``create()`` method on the ``Schema`` facade
161
- in your migration file. Pass it the collection name and a callback
162
- method with a ``MongoDB\Laravel\Schema\Blueprint`` parameter. Specify the
163
- index creation details on the ``Blueprint`` instance.
160
+ To create indexes, perform the following actions:
161
+
162
+ 1. Call the ``create()`` method on the ``Schema`` facade
163
+ in your migration file.
164
+
165
+ #. Pass it the collection name and a callback method with a
166
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
167
+
168
+ #. Specify the index creation details on the ``Blueprint`` instance.
164
169
165
170
The following example migration creates indexes on the following collection
166
171
fields:
@@ -262,11 +267,16 @@ indexes:
262
267
- Unique indexes, which prevent inserting documents that contain duplicate
263
268
values for the indexed field
264
269
265
- To create these index types, call the ``create()`` method on the ``Schema`` facade
266
- in your migration file. Pass ``create()`` the collection name and a callback
267
- method with a ``MongoDB\Laravel\Schema\Blueprint`` parameter. Call the
268
- appropriate helper method on the ``Blueprint`` instance and pass the
269
- index creation details.
270
+ To create these index types, perform the following actions:
271
+
272
+ 1. Call the ``create()`` method on the ``Schema`` facade
273
+ in your migration file.
274
+
275
+ #. Pass ``create()`` the collection name and a callback method with a
276
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
277
+
278
+ #. Call the appropriate helper method for the index type on the
279
+ ``Blueprint`` instance and pass the index creation details.
270
280
271
281
The following migration code shows how to create a sparse and a TTL index
272
282
by using the index helpers. Click the :guilabel:`{+code-output-label+}` button to see
@@ -339,10 +349,16 @@ Create a Geospatial Index
339
349
In MongoDB, geospatial indexes let you query geospatial coordinate data for
340
350
inclusion, intersection, and proximity.
341
351
342
- To create geospatial indexes, call the ``create()`` method on the ``Schema`` facade
343
- in your migration file. Pass ``create()`` the collection name and a callback
344
- method with a ``MongoDB\Laravel\Schema\Blueprint`` parameter. Specify the
345
- geospatial index creation details on the ``Blueprint`` instance.
352
+ To create geospatial indexes, perform the following actions:
353
+
354
+ 1. Call the ``create()`` method on the ``Schema`` facade
355
+ in your migration file.
356
+
357
+ #. Pass ``create()`` the collection name and a callback method with a
358
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
359
+
360
+ #. Specify the geospatial index creation details on the ``Blueprint``
361
+ instance.
346
362
347
363
The following example migration creates a ``2d`` and ``2dsphere`` geospatial
348
364
index on the ``spaceports`` collection. Click the :guilabel:`{+code-output-label+}`
@@ -379,11 +395,16 @@ the {+server-docs-name+}.
379
395
Drop an Index
380
396
~~~~~~~~~~~~~
381
397
382
- To drop indexes from a collection, call the ``table()`` method on the
383
- ``Schema`` facade in your migration file. Pass it the table name and a
384
- callback method with a ``MongoDB\Laravel\Schema\Blueprint`` parameter.
385
- Call the ``dropIndex()`` method with the index name on the ``Blueprint``
386
- instance.
398
+ To drop indexes from a collection, perform the following actions:
399
+
400
+ 1. Call the ``table()`` method on the ``Schema`` facade in your
401
+ migration file.
402
+
403
+ #. Pass it the table name and a callback method with a
404
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
405
+
406
+ #. Call the ``dropIndex()`` method with the index name on the
407
+ ``Blueprint`` instance.
387
408
388
409
.. note::
389
410
@@ -420,12 +441,16 @@ Vector Search features:
420
441
Atlas Search
421
442
````````````
422
443
423
- To create Atlas Search indexes, call the ``create()`` method on the
424
- ``Schema`` facade in your migration file. Pass ``create()`` the
425
- collection name and a callback method with a
426
- ``MongoDB\Laravel\Schema\Blueprint`` parameter. Pass the Atlas index
427
- creation details to the ``searchIndex()`` method on the ``Blueprint``
428
- instance.
444
+ To create Atlas Search indexes, perform the following actions:
445
+
446
+ 1. Call the ``create()`` method on the ``Schema`` facade in your
447
+ migration file.
448
+
449
+ #. Pass ``create()`` the collection name and a callback method with a
450
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
451
+
452
+ #. Pass the Atlas index creation details to the ``searchIndex()`` method
453
+ on the ``Blueprint`` instance.
429
454
430
455
This example migration creates the following Atlas Search indexes on the
431
456
``galaxies`` collection:
@@ -480,12 +505,16 @@ indexes created by running the migration:
480
505
Vector Search
481
506
`````````````
482
507
483
- To create Vector Search indexes, call the ``create()`` method on the
484
- ``Schema`` facade in your migration file. Pass ``create()`` the
485
- collection name and a callback method with a
486
- ``MongoDB\Laravel\Schema\Blueprint`` parameter. Pass the Atlas index
487
- creation details to the ``vectorSearchIndex()`` method on the ``Blueprint``
488
- instance.
508
+ To create Vector Search indexes, perform the following actions:
509
+
510
+ 1. Call the ``create()`` method on the ``Schema`` facade in your
511
+ migration file.
512
+
513
+ #. Pass ``create()`` the collection name and a callback method with a
514
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
515
+
516
+ #. Pass the vector index creation details to the ``vectorSearchIndex()``
517
+ method on the ``Blueprint`` instance.
489
518
490
519
The following example migration creates a Vector Search index called
491
520
``vs_index`` on the ``galaxies`` collection.
@@ -524,11 +553,16 @@ indexes created by running the migration:
524
553
Drop a Search Index
525
554
```````````````````
526
555
527
- To drop an Atlas Search or Vector Search index from a collection, call
528
- the ``table()`` method on the ``Schema`` facade in your migration file.
529
- Pass it the collection name and a callback method with a
530
- ``MongoDB\Laravel\Schema\Blueprint`` parameter. Call the ``dropSearchIndex()``
531
- method with the Search index name on the ``Blueprint`` instance.
556
+ To drop an Atlas Search or Vector Search index from a collection,
557
+ perform the following actions:
558
+
559
+ 1. Call the ``table()`` method on the ``Schema`` facade in your migration file.
560
+
561
+ #. Pass it the collection name and a callback method with a
562
+ ``MongoDB\Laravel\Schema\Blueprint`` parameter.
563
+
564
+ #. Call the ``dropSearchIndex()`` method with the Search index name on
565
+ the ``Blueprint`` instance.
532
566
533
567
The following example migration drops an index called ``auto_index``
534
568
from the ``galaxies`` collection:
0 commit comments