Skip to content

Commit b081578

Browse files
committed
Improve comment
1 parent d42def0 commit b081578

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
@@ -413,12 +413,15 @@ public function createSearchIndex($definition, array $options = []): string
413413
* Create one or more Atlas Search indexes for the collection.
414414
* Only available when used against a 7.0+ Atlas cluster.
415415
*
416-
* Each element in the $indexes array must have a "name" and a "definition" document.
416+
* Each element in the $indexes array must have "definition" document and they may have a "name" string.
417+
* The name can be omitted for a single index, in which case a name will be the default.
417418
* For example:
418419
*
419420
* $indexes = [
420-
* // Create a search index on all fields
421-
* [ 'name' => 'search_all', 'definition' => [ 'mappings' => [ 'dynamic' => true ] ] ],
421+
* // Create a search index with the default name, on
422+
* ['definition' => ['mappings' => ['dynamic' => false, 'fields' => ['title' => ['type' => 'string']]]]],
423+
* // Create a named search index on all fields
424+
* ['name' => 'search_all', 'definition' => ['mappings' => ['dynamic' => true]]],
422425
* ];
423426
*
424427
* @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
@@ -544,6 +544,7 @@ private function executeForCollection(Collection $collection)
544544
case 'createSearchIndex':
545545
$options = [];
546546
if (isset($args['name'])) {
547+
assertIsString($args['name']);
547548
$options['name'] = $args['name'];
548549
}
549550

0 commit comments

Comments
 (0)