Skip to content

Commit 74c9577

Browse files
[SCOUT] Adding Declaring Model Engine to Scout docs (#7952)
* Adding Declaring Model Engine to Scout docs * Matching styling of docs by pulling in EngineManager namespace as import * formatting Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 653985a commit 74c9577

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

scout.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Configuring Model Indexes](#configuring-model-indexes)
99
- [Configuring Searchable Data](#configuring-searchable-data)
1010
- [Configuring The Model ID](#configuring-the-model-id)
11+
- [Configuring Search Engines Per Model](#configuring-search-engines-per-model)
1112
- [Identifying Users](#identifying-users)
1213
- [Database / Collection Engines](#database-and-collection-engines)
1314
- [Database Engine](#database-engine)
@@ -209,6 +210,34 @@ By default, Scout will use the primary key of the model as model's unique ID / k
209210
}
210211
}
211212

213+
<a name="configuring-search-engines-per-model"></a>
214+
### Configuring Search Engines Per Model
215+
216+
When searching, Scout will typically use the default search engine specified in your application's `scout` configuration file. However, the search engine for a particular model can be changed by overriding the `searchableUsing` method on the model:
217+
218+
<?php
219+
220+
namespace App\Models;
221+
222+
use Illuminate\Database\Eloquent\Model;
223+
use Laravel\Scout\EngineManager;
224+
use Laravel\Scout\Searchable;
225+
226+
class User extends Model
227+
{
228+
use Searchable;
229+
230+
/**
231+
* Get the engine used to index the model.
232+
*
233+
* @return \Laravel\Scout\Engines\Engine
234+
*/
235+
public function searchableUsing()
236+
{
237+
return app(EngineManager::class)->engine('meilisearch');
238+
}
239+
}
240+
212241
<a name="identifying-users"></a>
213242
### Identifying Users
214243

0 commit comments

Comments
 (0)