@@ -181,12 +181,6 @@ Use the following syntax to run a find operation that matches all documents:
181
181
Search Text Fields
182
182
------------------
183
183
184
- You can perform a text search by using the :manual:`$text
185
- </reference/operator/query/text>` operator followed
186
- by the ``$search`` field in your query filter that you pass to the
187
- ``where()`` method. The ``$text`` operator performs a text search on the
188
- text-indexed fields. The ``$search`` field specifies the text to search for.
189
-
190
184
A text search retrieves documents that contain a **term** or a **phrase** in the
191
185
text-indexed fields. A term is a sequence of characters that excludes
192
186
whitespace characters. A phrase is a sequence of terms with any number
@@ -200,12 +194,19 @@ of whitespace characters.
200
194
indexes, see the :ref:`laravel-eloquent-indexes` section of the
201
195
Schema Builder guide.
202
196
197
+ You can perform a text search by using the :manual:`$text
198
+ </reference/operator/query/text>` operator followed
199
+ by the ``$search`` field in your query filter that you pass to the
200
+ ``where()`` method. The ``$text`` operator performs a text search on the
201
+ text-indexed fields. The ``$search`` field specifies the text to search for.
202
+
203
203
After building your query with the ``where()`` method, chain the ``get()``
204
204
method to retrieve the query results.
205
205
206
206
This example calls the ``where()`` method on the ``Movie`` Eloquent model to
207
207
retrieve documents in which the ``plot`` field contains the phrase
208
- ``"love story"``:
208
+ ``"love story"``. To perform this text search, the collection must have
209
+ a text index on the ``plot`` field.
209
210
210
211
.. tabs::
211
212
@@ -271,16 +272,12 @@ retrieve documents in which the ``plot`` field contains the phrase
271
272
Plot: A girl. A boy. A love story ...
272
273
273
274
...
274
-
275
- .. note::
276
-
277
- To specify a phrase as the text search criteria, you must include it
278
- with escaped quotes in the query filter.
279
275
280
- A text search assigns a numerical text score to indicate how closely
276
+ A text search assigns a numerical :manual:` text score </reference/operator/query/text/#text-score>` to indicate how closely
281
277
each result matches the string in your query filter. You can sort the
282
278
results by relevance by using the ``orderBy()`` method to sort on the
283
- ``textScore`` metadata:
279
+ ``textScore`` metadata field. You can access this metadata by using the
280
+ :manual:`$meta </reference/operator/aggregation/meta/>` operator:
284
281
285
282
.. literalinclude:: /includes/fundamentals/read-operations/ReadOperationsTest.php
286
283
:language: php
0 commit comments