Skip to content

Commit a409ac9

Browse files
committed
Improve comment
1 parent 0b2eea5 commit a409ac9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Collection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,15 @@ public function createSearchIndex($definition, array $options = []): string
426426
* Create one or more Atlas Search indexes for the collection.
427427
* Only available when used against a 7.0+ Atlas cluster.
428428
*
429-
* Each element in the $indexes array must have a "name" and a "definition" document.
429+
* Each element in the $indexes array must have "definition" document and they may have a "name" string.
430+
* The name can be omitted for a single index, in which case a name will be the default.
430431
* For example:
431432
*
432433
* $indexes = [
433-
* // Create a search index on all fields
434-
* [ 'name' => 'search_all', 'definition' => [ 'mappings' => [ 'dynamic' => true ] ] ],
434+
* // Create a search index with the default name, on
435+
* ['definition' => ['mappings' => ['dynamic' => false, 'fields' => ['title' => ['type' => 'string']]]]],
436+
* // Create a named search index on all fields
437+
* ['name' => 'search_all', 'definition' => ['mappings' => ['dynamic' => true]]],
435438
* ];
436439
*
437440
* @see https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/

tests/UnifiedSpecTests/Operation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ function (IndexInfo $info) {
560560
case 'createSearchIndex':
561561
$options = [];
562562
if (isset($args['name'])) {
563+
assertIsString($args['name']);
563564
$options['name'] = $args['name'];
564565
}
565566

0 commit comments

Comments
 (0)