Skip to content

Commit f57dfa1

Browse files
authored
PHPLIB-1321: Use correct method in createSearchIndexes() example (#1225)
1 parent 02b6d3a commit f57dfa1

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

docs/reference/method/MongoDBCollection-createSearchIndexes.txt

+14-7
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Behavior
7777
Examples
7878
--------
7979

80-
Create Indexes with Static and Dynamic Mappings
81-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80+
Create an Index with Dynamic Mappings
81+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8282

8383
The following example creates an Atlas Search index using
8484
`dynamic mappings <https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/#dynamic-mappings>`__
@@ -91,18 +91,25 @@ to index all document fields containing
9191

9292
$collection = (new MongoDB\Client)->selectCollection('test', 'articles');
9393

94-
$indexName = $collection->createSearchIndex(
95-
['mappings' => ['dynamic' => true]],
96-
['name' => 'test-search-index']
94+
$indexNames = $collection->createSearchIndexes(
95+
[
96+
[
97+
'name' => 'test-search-index',
98+
'definition' => ['mappings' => ['dynamic' => true]],
99+
],
100+
]
97101
);
98102

99-
var_dump($indexName);
103+
var_dump($indexNames);
100104

101105
The output would then resemble:
102106

103107
.. code-block:: none
104108

105-
string(17) "test-search-index"
109+
array(1) {
110+
[0]=>
111+
string(17) "test-search-index"
112+
}
106113

107114
See Also
108115
--------

0 commit comments

Comments
 (0)