Full-text Search
Laravix indexes content for full-text search through Laravel Scout. Out of the box a database-backed driver works with zero infrastructure; for typo-tolerant, ranked search you plug in Meilisearch. This article covers what gets indexed, driver setup and reindexing.
What is indexed
The searchable model is Laravix\Cms\Models\Content. Each record indexes:
titleandslug,search_text— plain text extracted from the visual builder HTML, classic blocks and all field values (capped at 60,000 characters), refreshed automatically on save,- plus
site_id,typeandlocalefor filtering.
Only content that is published (and past its publish date) is searchable; unpublishing or deleting removes it from the index automatically.
Who uses the index
- the headless endpoint
GET /api/v1/search(API Reference), - the docs plugin's search box (
/docs/search), - any
Content::search('term')call you write yourself.
Choosing a driver
Set the driver in .env:
SCOUT_DRIVER=database
| Driver | Setup | Search quality |
|---|---|---|
collection |
none | Basic substring matching; fine for tiny sites |
database |
none | LIKE-based matching in SQL |
meilisearch |
run a Meilisearch server | Typo-tolerant, ranked, fast — recommended for production |
Setting up Meilisearch
-
Run a Meilisearch instance (in the dev monorepo, Sail already ships one).
-
Configure
.env:SCOUT_DRIVER=meilisearch MEILISEARCH_HOST=http://127.0.0.1:7700 MEILISEARCH_KEY=your-master-key -
Push the index settings — Laravix pre-configures them in
config/scout.php(filterable:site_id,type,locale; searchable:title,slug,search_text):php artisan scout:sync-index-settings -
Import existing content:
php artisan scout:import "Laravix\Cms\Models\Content"
From here on, saves keep the index in sync automatically. For busy sites set SCOUT_QUEUE=true so index updates run on the queue worker.
Reindexing
After bulk imports, driver changes or suspicious results:
php artisan scout:flush "Laravix\Cms\Models\Content"
php artisan scout:import "Laravix\Cms\Models\Content"
Troubleshooting
Search returns nothing. Check the content is published, the driver is set, and (for Meilisearch) the import ran without errors — the Meilisearch web dashboard on port 7700 shows the index contents.
Results ignore the site or language. Filtering by site_id and locale requires the index settings — run scout:sync-index-settings after changing drivers.
Edits don't show up in results. With SCOUT_QUEUE=true, index updates wait for the queue worker — make sure it's running.