Your users type a word into the search box and expect results in milliseconds — ranked, typo-tolerant, and fast even when your table holds a million rows. The usual first attempt is a LIKE '%query%' clause, and it works right up until it doesn’t: no ranking, no typo tolerance, and a full table scan on every keystroke. Laravel Scout is the official way out. It is a driver-based package that adds full-text search to your Eloquent models, keeps a search index in sync with your database automatically, and lets you swap the underlying engine — Meilisearch, Algolia, Typesense, Turbopuffer, or your own database — without rewriting your search code.
Verified against the official Laravel 13.x Scout documentation and the Meilisearch and Algolia pricing pages on 19 November 2026.
Why LIKE queries stop working
A LIKE '%term%' query cannot use a normal B-tree index, because the leading wildcard forces the database to inspect every row — a slow full scan that competes with your normal traffic on any sizeable table. Worse, the results are unordered — a row that mentions the term once in the footer ranks the same as a row with the term in the title — and a single typo returns nothing at all.
A dedicated search engine solves all three problems at once: it builds an inverted index so lookups are near-instant, it ranks results by relevance (title matches beat body matches), and it tolerates typos and prefixes. Scout is the bridge between your Eloquent models and that engine, and the bridge is thin enough that your controllers barely change.
What Laravel Scout actually does
Scout is not a search engine. It is a driver-based layer that sits between Eloquent and one. You add the Searchable trait to a model, and Scout registers model observers that keep your search index in sync: save a model and it is added to the index, update it and the index entry updates, delete it and the entry is removed. Searching is one method call:
$posts = Post::search('laravel queues')->get();
That returns a collection of Eloquent models, so everything downstream — Blade views, API resources, pagination — works exactly as it does with a normal query. The engine behind it is a configuration choice, not a code choice, which is the whole point: start on the free database engine, move to Meilisearch when you need typo tolerance, and your controllers never notice.
Laravel Scout drivers: which one should you pick?
Scout ships with six engines. Pick by how much search matters to your app, not by what sounds impressive.
| Driver | Best for | Trade-off |
|---|---|---|
| database | Small apps, side projects, zero new infrastructure | No typo tolerance or relevance ranking beyond your DB’s full-text index |
| collection | Prototypes, tests, a few hundred records | Loads every record into PHP and filters there — never for production data |
| Meilisearch | Most Laravel apps: self-hosted, open source, typo-tolerant | You run one more service (or pay for Cloud) |
| Algolia | Teams that want zero infrastructure and rich analytics | Metered billing: the free plan covers 10,000 searches and 50,000 records a month |
| Typesense | Self-hosted search with strong typo tolerance and geo search | Smaller ecosystem than Meilisearch in the Laravel world |
| Turbopuffer | Semantic and hybrid search at scale | Newest driver; the smallest body of Laravel-specific guidance |
For most apps the honest answer is the database engine first, Meilisearch second. The database engine needs no new service at all — it searches your existing MySQL or PostgreSQL tables using full-text indexes and LIKE clauses — and for many apps it is all you will ever need. Move to Meilisearch when users start complaining that search “doesn’t find anything” because of a typo, or when you want faceted filtering and relevance ranking that a database cannot give you.
Setting up Laravel Scout with Meilisearch
Install Scout and publish its configuration file:
composer require laravel/scout
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
Meilisearch needs its PHP SDK as well:
composer require meilisearch/meilisearch-php http-interop/http-factory-guzzle
Then point Scout at Meilisearch in your .env file:
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=masterKey
You still need a Meilisearch server running. Locally, the fastest route is Laravel Sail, which ships a Meilisearch service you can enable, or a single Docker container:
docker run -d --name meilisearch -p 7700:7700 \
-e MEILI_MASTER_KEY=masterKey \
getmeili/meilisearch:latest
In production, either self-host that same binary on your VPS — a single static binary, free under the MIT licence — or use Meilisearch Cloud, from around $20 a month with a 14-day trial and no permanently free tier. Self-hosting costs a server you already have; Cloud costs money and removes the ops work.
Making a model searchable
Add the trait to any model you want indexed:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
class Post extends Model
{
use Searchable;
}
From that moment, every save(), create(), and delete() on a post updates the index. By default Scout indexes the model’s entire toArray() output. That is convenient and usually wrong in production: it ships every column — including anything sensitive — into a second system. Define exactly what goes in:
public function toSearchableArray(): array
{
return [
'id' => (int) $this->id,
'title' => $this->title,
'body' => $this->body,
'status' => $this->status,
'author_name' => $this->author->name,
'published_at' => $this->published_at?->timestamp,
];
}
Three details matter here. First, cast numeric fields to their real types — Meilisearch only applies range filters (>, <) to correctly typed data, so a price stored as a string silently breaks your filters. Second, you can pull in relationship data, like the author name above, but keep the payload small: every extra field is indexed, stored, and returned. Third, if you eager-load a relationship inside toSearchableArray on every save, you have added a query to every write — load it once in makeSearchableUsing instead when you batch-import (see below).
Two more model hooks cover the common edge cases. searchableAs() renames the index (handy for prefixing indexes per environment so staging never pollutes production):
public function searchableAs(): string
{
return 'posts_index';
}
And shouldBeSearchable() decides whether a record belongs in the index at all — the classic use is keeping drafts out of search:
public function shouldBeSearchable(): bool
{
return $this->status === 'published';
}
Note the trap: shouldBeSearchable only applies to saves, creates, and queries. Calling ->searchable() directly on a model or collection overrides it. And it does not apply to the database engine at all — there, use where clauses instead, because the data is always in the database.
Finally, if your model changes often for reasons unrelated to search — a view counter, a last_seen_at timestamp — stop Scout reindexing on every touch:
public function searchIndexShouldBeUpdated(): bool
{
return $this->wasRecentlyCreated || $this->wasChanged(['title', 'body']);
}
On a high-traffic app this one method can cut your indexing load by an order of magnitude.
Importing your existing data
Adding the trait does not index the rows already in your database. Import them with Artisan:
php artisan scout:import "App\Models\Post"
For a large table, queue the import so it does not block your terminal or time out:
php artisan scout:queue-import "App\Models\Post" --chunk=500
If the import query needs eager-loaded relationships, customise it with makeAllSearchableUsing — but beware the documented gotcha: when the import runs through the queue, relationships eager-loaded there are fetched again in full inside the job, so any constraints you applied are lost. Constrain relationships in makeSearchableUsing instead, which runs inside the job:
protected function makeAllSearchableUsing(Builder $query): Builder
{
return $query->with('author');
}
public function makeSearchableUsing(Collection $models): Collection
{
return $models->load('author');
}
To start over, flush the index and re-import:
php artisan scout:flush "App\Models\Post"
php artisan scout:import "App\Models\Post"
And when you run a migration or seeder that touches thousands of rows, wrap it so Scout stays out of the way, then import once at the end:
Post::withoutSyncingToSearch(function () {
// Bulk updates, seeding, backfills...
});
Forgetting this is the most common reason a seed or backfill takes ten times longer than it should: every single save fires an indexing round-trip.
Searching with Scout
The search itself is the easy part. search() takes the query string and returns a builder; get() gives you Eloquent models:
use App\Models\Post;
$posts = Post::search('laravel queues')->get();
Need the raw engine response — scores, facets, highlighting — instead of models? Use raw():
$results = Post::search('laravel queues')->raw();
Where clauses filter inside the engine, before results are ranked and paginated. That distinction matters: filtering after the fact in PHP can return a page full of another tenant’s results with none of your own. Always filter with Scout:
$posts = Post::search('queues')
->where('status', 'published')
->where('author_id', $user->id)
->whereIn('category', ['backend', 'devops'])
->where('published_at', '>=', now()->subYear()->timestamp)
->orderBy('published_at', 'desc')
->paginate(15);
Supported operators are =, !=, <, >, <=, >=, plus whereIn and whereNotIn. One prerequisite catches almost everyone: with Meilisearch, every attribute you filter or sort on must be declared filterable or sortable in your index settings first (next section) — otherwise the where clause fails at runtime, not at boot.
Pagination works like Eloquent pagination and returns a LengthAwarePaginator, so your existing Blade $posts->links() works unchanged:
Route::get('/search', function (Request $request) {
return Post::search($request->input('query'))->paginate(15);
});
Two more tools round out the query API. The query() callback customises the Eloquent query that fetches the matched models — for example to eager-load a relationship — but note it runs after the engine has chosen the matches, so it cannot filter results; use where clauses for that. And if your models use soft deletes, set 'soft_delete' => true in config/scout.php and Scout keeps trashed records in the index with a hidden __soft_deleted flag, retrievable with ->withTrashed() or ->onlyTrashed(). A forceDelete() removes the record from the index automatically.
Index settings that make filters work
Meilisearch and Algolia both need to know in advance which attributes are filterable and sortable. Declare them in config/scout.php:
'meilisearch' => [
'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
'key' => env('MEILISEARCH_KEY', null),
'index-settings' => [
Post::class => [
'filterableAttributes' => ['id', 'status', 'author_id', 'category', 'published_at'],
'sortableAttributes' => ['published_at'],
],
],
],
Then push the settings to the engine — and make this part of your deployment, not a manual step you remember once:
php artisan scout:sync-index-settings
If a model is soft deletable, add it to index-settings even with an empty array, so Scout configures the __soft_deleted filtering for you.
Queueing Scout indexing in production
By default Scout indexes synchronously: every save waits for a round-trip to the search engine before the HTTP response returns. On a write-heavy app that is a latency tax on every request, and during a bulk import it is a disaster. Turn on queueing in config/scout.php:
'queue' => true,
Or as an array, to give Scout its own queue and connection so a flood of indexing jobs never blocks your mail or notification jobs:
'queue' => [
'connection' => 'redis',
'queue' => 'scout',
],
php artisan queue:work redis --queue=scout
Run that worker under Supervisor, exactly as you would any queue worker — if you have not set up Supervisor yet, the blog’s Laravel queue workers guide covers the full config. Two subtleties: first, even with queueing on, Algolia and Meilisearch index asynchronously on their side, so a record can be saved but not yet searchable for a moment — do not write a test that saves and immediately searches without accounting for that. Second, in write-heavy apps the same record can accumulate duplicate indexing jobs; opt into unique jobs in a service provider and Laravel’s unique job locks will collapse them:
use Laravel\Scout\Jobs\MakeSearchableUniquely;
use Laravel\Scout\Jobs\RemoveFromSearchUniquely;
use Laravel\Scout\Scout;
Scout::makeSearchableUsing(MakeSearchableUniquely::class);
Scout::removeFromSearchUsing(RemoveFromSearchUniquely::class);
Semantic and hybrid search, briefly
Keyword search fails when the user describes what they want instead of naming it: “how do I make my site faster” should find your caching guide even though it never uses the word “faster”. Scout’s Meilisearch, Typesense, and Turbopuffer drivers support semantic search (meaning-based) and hybrid search (keyword plus meaning) for exactly this. You configure an embedder in your index settings, define a toSearchableEmbedding method that returns the text to embed, and query with:
$articles = Article::search('staying cool in the summer')
->semantic()
->get();
// Or weighted hybrid: text weight 1, semantic weight 2
$articles = Article::search('renewable energy storage')
->hybrid(textWeight: 1, semanticWeight: 2)
->get();
When Scout generates embeddings itself it uses the Laravel AI SDK, so you need an embedding provider configured; Meilisearch and Turbopuffer can also generate embeddings natively. Treat this as a second phase: get keyword search, filters, and queueing right first — semantic search on a broken index is still broken search.
The database engine: search without a server
If you do not want another service, set SCOUT_DRIVER=database and Scout searches your MySQL or PostgreSQL tables directly — no indexing step, no import, no sync command. It is the simplest way to add search, and for many apps it is enough. You can tune which columns use which strategy with attributes on toSearchableArray:
use Laravel\Scout\Attributes\SearchUsingFullText;
use Laravel\Scout\Attributes\SearchUsingPrefix;
#[SearchUsingPrefix(['id', 'email'])]
#[SearchUsingFullText(['bio'])]
public function toSearchableArray(): array
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'bio' => $this->bio,
];
}
Columns without an attribute fall back to LIKE. Before marking a column for full-text search, make sure it actually has a full-text index — add one in a migration with $table->fullText(['title', 'body']). On PostgreSQL, Scout goes further: a $table->searchable() migration helper creates a weighted tsvector column with a GIN index, and the database engine supports semantic and hybrid search via the pgvector extension. The ceiling is real, though: no typo tolerance on MySQL, and relevance ranking is cruder than a dedicated engine. Treat the database engine as the starting point, not the destination, if search is a core feature of your product.
7 mistakes that break Laravel Scout search
- Indexing everything. The default
toArray()payload ships every column, including secrets and blobs, into your search engine. DefinetoSearchableArrayexplicitly. - Forgetting
scout:import. The trait only syncs changes after it is added. Existing rows are invisible until you import them. - Filtering on attributes you never declared. Meilisearch where clauses need
filterableAttributesset and synced. The error shows up at runtime, in production, on the first filtered search. - Indexing synchronously in production. Every save waits on the engine. Set
'queue' => trueand run a dedicated worker before your first traffic spike, not after it. - Reindexing on every touch. A view counter that bumps on every page load reindexes the model on every page load. Use
searchIndexShouldBeUpdatedto skip irrelevant changes. - Searching immediately after saving in tests. Meilisearch and Algolia index asynchronously, so the record may not be searchable yet. Use the database or collection driver in tests, or wait for the index.
- One index for every environment. Without a prefix or a per-model
searchableAs(), your staging seeds land in the production index. Namespace your indexes per environment.
Production checklist
- Set
SCOUT_DRIVERper environment; never let staging and production share an index name. - Queue indexing (
'queue' => true) with a dedicated queue and a Supervisor-managed worker. - Add
php artisan scout:sync-index-settingsto your deploy script, after every config change. - Protect Meilisearch with a master key and never expose port 7700 publicly; put it behind your private network or a reverse proxy with auth.
- Re-import after any change to
toSearchableArray— existing records keep their old indexed shape until you do. - Monitor the scout queue length like any other queue: a growing backlog means search results are going stale.
The verdict
Scout earns its place because it makes the boring parts of search disappear: the trait handles syncing, the builder API means your controllers look like Eloquent, and the driver system lets you start free on the database engine and graduate to Meilisearch when typo tolerance and ranking matter — without rewriting a line of search code. Start with the database engine if you are unsure, add Meilisearch when your users start typing like humans instead of machines, queue your indexing from day one, and keep your indexed payload deliberately small. Search is one of those features users only notice when it is broken; Scout is how you make sure they never do.
Further Reading & References
- Laravel Scout — official Laravel 13.x documentation (install, drivers, queueing, searching, semantic search)
- Laravel Scout guide — Meilisearch docs (updated 16 November 2026; setup, semantic and hybrid search)
- A complete guide to full-text search with Laravel — Meilisearch blog
- Full-Text Search in Multi-Tenant Laravel SaaS (tenant isolation, queue discipline, relevance tuning)
- Setting Up Meilisearch for Lightning-Fast Laravel Scout Search — DEV
- How to Implement Full-Text Search in Laravel Scout — CodeWolfy
- Algolia Alternatives for Indie Developers (2026, Priced) (Algolia free plan: 10,000 searches, 50,000 records a month; Meilisearch Cloud from ~$20/month)
- Typesense pricing in 2026: what it costs and how Meilisearch compares — Meilisearch blog
- How to Run Laravel Queue Workers in Production with Supervisor (2026) — HowToShipIt
- How to Speed Up Laravel Queries: 10 Fixes to Try Before You Upgrade Your Server (2026) — HowToShipIt



