@@ -32,36 +32,42 @@ functionality:
3232- Provides an abstraction to create :atlas:`Atlas Search indexes
3333 </atlas-search/manage-indexes/>` from any MongoDB or SQL model.
3434
35- .. tip::
35+ .. important:: Use Schema Builder to Create Search Indexes
3636
37- We recommend creating Search indexes by using the ``Schema``
38- builder methods. To learn more, see the :ref:`TODO DOCSP-46230`
39- section of the Atlas Search guide.
37+ If your documents are already in MongoDB, create Search indexes
38+ by using {+php-library+} or ``Schema`` builder methods to improve
39+ search query performance. To learn more about creating Search
40+ indexes, see the :ref:`laravel-as-index` section of the Atlas
41+ Search guide.
4042
4143- Allows you to automatically replicate data from MongoDB into a
4244 search engine such as `Meilisearch <https://www.meilisearch.com/>`__
4345 or `Algolia <https://www.algolia.com/>`__. You can use a MongoDB Eloquent
44- model as the source to import and index.
46+ model as the source to import and index. To learn more about indexing
47+ to a search engine, see the `Indexing
48+ <https://laravel.com/docs/{+laravel-docs-version+}/scout#indexing>`__
49+ section of the Laravel Scout documentation.
4550
46- .. note :: Deployment Compatibility
51+ .. important :: Deployment Compatibility
4752
4853 You can use Laravel Scout only when you connect to MongoDB Atlas
49- deployments. This feature is not available for self-managed or
50- serverless deployments.
54+ deployments. This feature is not available for self-managed
55+ deployments.
5156
5257Scout for Atlas Search Tutorial
5358-------------------------------
5459
55- This section demonstrates how to use the Scout integration in your
56- application to support Atlas Search queries .
60+ This tutorial demonstrates how to use Scout to compound and index
61+ documents for MongoDB Atlas Search from Eloquent models (MongoDB or SQL) .
5762
5863.. procedure::
5964 :style: connected
6065
6166 .. step:: Install the Scout package
6267
6368 Before you can use Scout in your application, run the following
64- command from your application's root directory to install Laravel Scout:
69+ command from your application's root directory to install the
70+ ``laravel/scout`` package:
6571
6672 .. code-block:: bash
6773
@@ -91,6 +97,12 @@ application to support Atlas Search queries.
9197 protected $connection = 'mongodb';
9298 }
9399
100+ The ``Searchable`` trait also allows you to reformat documents,
101+ embed related documents, or transform document values. To learn
102+ more, see the `Configuring Searchable Data
103+ <https://laravel.com/docs/{+laravel-docs-version+}/scout#configuring-searchable-data>`__
104+ section of the Laravel Scout documentation.
105+
94106 .. step:: Configure Scout in your application
95107
96108 Ensure that your application is configured to use MongoDB as its
@@ -124,6 +136,11 @@ application to support Atlas Search queries.
124136 - Specifies ``scout_`` as the prefix for the collection name of the
125137 searchable collection
126138
139+ In the ``config/scout.php`` file, you can also specify a custom
140+ Atlas Search index definition. To learn more, see the :ref:`custom
141+ index definition example <laravel-scout-custom-index>` in the
142+ following step.
143+
127144 Set the following environment variable in your application's
128145 ``.env`` file to select ``mongodb`` as the default search driver:
129146
@@ -154,7 +171,7 @@ application to support Atlas Search queries.
154171 command creates the search collection with an Atlas Search index in your
155172 MongoDB database. The collection is named ``scout_movies``, based on the prefix
156173 set in the preceding step. The Atlas Search index is named ``scout``
157- and has the following configuration:
174+ and has the following configuration by default :
158175
159176 .. code-block:: json
160177
@@ -163,7 +180,28 @@ application to support Atlas Search queries.
163180 "dynamic": true
164181 }
165182 }
166-
183+
184+ .. _laravel-scout-custom-index:
185+
186+ To customize the index definition, add the ``index-definitions``
187+ configuration to the ``mongodb`` entry in your
188+ ``config/scout.php`` file. The following code demonstrates how to
189+ specify a custom index definition for the ``scout_index`` index:
190+
191+ .. code-block:: php
192+
193+ 'mongodb' => [
194+ 'connection' => env('SCOUT_MONGODB_CONNECTION', 'mongodb'),
195+ 'index-definitions' => [
196+ 'scout_index' => [
197+ 'mappings' => [
198+ 'dynamic' => false,
199+ 'fields' => ['title' => ['type' => 'string']]
200+ ]
201+ ]
202+ ]
203+ ], ...
204+
167205 .. note::
168206
169207 MongoDB can take up to a minute to create and finalize
@@ -172,10 +210,11 @@ application to support Atlas Search queries.
172210
173211 .. step:: Import data into the searchable collection
174212
175- You can use Scout to replicate data from a source collection into a
176- searchable collection. The following command replicates and indexes data
177- from the ``movies`` collection into the ``scout_movies`` collection
178- created in the preceding step:
213+ You can use Scout to replicate data from a source collection
214+ modeled by your Eloquent model into a searchable collection. The
215+ following command replicates and indexes data from the ``movies``
216+ collection into the ``scout_movies`` collection indexed in the
217+ preceding step:
179218
180219 .. code-block:: bash
181220
@@ -186,7 +225,7 @@ application to support Atlas Search queries.
186225 .. tip:: Select Fields to Import
187226
188227 You might not need all the fields from your source documents in your
189- searchable collection. Limiting the fields you replicate can improve
228+ searchable collection. Limiting the amount of data you replicate can improve
190229 your application's speed and performance.
191230
192231 You can select specific fields to import by defining the
@@ -209,11 +248,6 @@ application to support Atlas Search queries.
209248 }
210249
211250After completing these steps, you can perform Atlas Search queries on the
212- ``scout_movies`` collection in your {+odm-long+} application.
213-
214- .. TODO add link to Atlas Search guide
215-
216- .. TODO Use an External Search Engine
217- .. -----------------------------
218-
219- .. TODO https://jira.mongodb.org/browse/DOCSP-45125
251+ ``scout_movies`` collection in your {+odm-long+} application. To learn
252+ how to perform full-text searches, see the :ref:`laravel-atlas-search`
253+ guide.
0 commit comments