@@ -56,7 +56,25 @@ documentation.
5656Create an Atlas Search Index
5757----------------------------
5858
59- .. TODO in DOCSP-46230
59+ You can create an Atlas Search index in either of the following ways:
60+
61+ - Call the ``create()`` method on the ``Schema`` facade and pass the
62+ ``searchIndex()`` helper method with index creation details. To learn
63+ more about this strategy, see the
64+ :ref:`laravel-schema-builder-atlas-idx` section of the Schema Builder guide.
65+
66+ - Access a collection, then call the
67+ :phpmethod:`MongoDB\Collection::createSearchIndex()` from the
68+ {+php-library+}, as shown in the following code:
69+
70+ .. code-block:: php
71+
72+ $collection = DB::connection('mongodb')->getCollection('movies');
73+
74+ $collection->createSearchIndex(
75+ ['mappings' => ['dynamic' => true]],
76+ ['name' => 'search_index']
77+ );
6078
6179Perform Queries
6280---------------
@@ -93,23 +111,23 @@ model's ``title`` field for the term ``'dream'``:
93111 :copyable: true
94112
95113 .. input:: /includes/fundamentals/as-avs/AtlasSearchTest.php
96- :language: php
97- :dedent:
98- :start-after: start-search-query
99- :end-before: end-search-query
114+ :language: php
115+ :dedent:
116+ :start-after: start-search-query
117+ :end-before: end-search-query
100118
101119 .. output::
102- :language: json
103- :visible: false
104-
105- [
106- { "title": "Dreaming of Jakarta",
107- "year": 1990
108- },
109- { "title": "See You in My Dreams",
110- "year": 1996
111- }
112- ]
120+ :language: json
121+ :visible: false
122+
123+ [
124+ { "title": "Dreaming of Jakarta",
125+ "year": 1990
126+ },
127+ { "title": "See You in My Dreams",
128+ "year": 1996
129+ }
130+ ]
113131
114132You can use the ``search()`` method to perform many types of Atlas
115133Search queries. Depending on your desired query, you can pass the
@@ -119,55 +137,55 @@ following optional parameters to ``search()``:
119137 :header-rows: 1
120138
121139 * - Optional Parameter
122- - Type
123- - Description
140+ - Type
141+ - Description
124142
125143 * - ``index``
126- - ``string``
127- - Provides the name of the Atlas Search index to use
144+ - ``string``
145+ - Provides the name of the Atlas Search index to use
128146
129147 * - ``highlight``
130- - ``array``
131- - Specifies highlighting options for displaying search terms in their
132- original context
148+ - ``array``
149+ - Specifies highlighting options for displaying search terms in their
150+ original context
133151
134152 * - ``concurrent``
135- - ``bool``
136- - Parallelizes search query across segments on dedicated search nodes
153+ - ``bool``
154+ - Parallelizes search query across segments on dedicated search nodes
137155
138156 * - ``count``
139- - ``string``
140- - Specifies the count options for retrieving a count of the results
157+ - ``string``
158+ - Specifies the count options for retrieving a count of the results
141159
142160 * - ``searchAfter``
143- - ``string``
144- - Specifies a reference point for returning documents starting
145- immediately following that point
161+ - ``string``
162+ - Specifies a reference point for returning documents starting
163+ immediately following that point
146164
147165 * - ``searchBefore``
148- - ``string``
149- - Specifies a reference point for returning documents starting
150- immediately preceding that point
166+ - ``string``
167+ - Specifies a reference point for returning documents starting
168+ immediately preceding that point
151169
152170 * - ``scoreDetails``
153- - ``bool``
154- - Specifies whether to retrieve a detailed breakdown of the score
155- for results
171+ - ``bool``
172+ - Specifies whether to retrieve a detailed breakdown of the score
173+ for results
156174
157175 * - ``sort``
158- - ``array``
159- - Specifies the fields on which to sort the results
176+ - ``array``
177+ - Specifies the fields on which to sort the results
160178
161179 * - ``returnStoredSource``
162- - ``bool``
163- - Specifies whether to perform a full document lookup on the
164- backend database or return only stored source fields directly
165- from Atlas Search
180+ - ``bool``
181+ - Specifies whether to perform a full document lookup on the
182+ backend database or return only stored source fields directly
183+ from Atlas Search
166184
167185 * - ``tracking``
168- - ``array``
169- - Specifies the tracking option to retrieve analytics information
170- on the search terms
186+ - ``array``
187+ - Specifies the tracking option to retrieve analytics information
188+ on the search terms
171189
172190To learn more about these parameters, see the :atlas:`Fields
173191</atlas-search/aggregation-stages/search/#fields>` section of the
@@ -200,20 +218,20 @@ string ``"jak"`` on the ``title`` field:
200218 :copyable: true
201219
202220 .. input:: /includes/fundamentals/as-avs/AtlasSearchTest.php
203- :language: php
204- :dedent:
205- :start-after: start-auto-query
206- :end-before: end-auto-query
221+ :language: php
222+ :dedent:
223+ :start-after: start-auto-query
224+ :end-before: end-auto-query
207225
208226 .. output::
209- :language: json
210- :visible: false
227+ :language: json
228+ :visible: false
211229
212- [
213- "Dreaming of Jakarta",
214- "Jakob the Liar",
215- "Emily Calling Jake"
216- ]
230+ [
231+ "Dreaming of Jakarta",
232+ "Jakob the Liar",
233+ "Emily Calling Jake"
234+ ]
217235
218236You can also pass the following optional parameters to the ``autocomplete()``
219237method to customize the query:
@@ -222,19 +240,19 @@ method to customize the query:
222240 :header-rows: 1
223241
224242 * - Optional Parameter
225- - Type
226- - Description
227- - Default Value
243+ - Type
244+ - Description
245+ - Default Value
228246
229247 * - ``fuzzy``
230- - ``bool`` or ``array``
231- - Enables fuzzy search and fuzzy search options
232- - ``false``
248+ - ``bool`` or ``array``
249+ - Enables fuzzy search and fuzzy search options
250+ - ``false``
233251
234252 * - ``tokenOrder``
235- - ``string``
236- - Specifies order in which to search for tokens
237- - ``'any'``
253+ - ``string``
254+ - Specifies order in which to search for tokens
255+ - ``'any'``
238256
239257To learn more about these parameters, see the :atlas:`Options
240258</atlas-search/autocomplete/#options>` section of the
0 commit comments