Meilisearch
Overview
Meilisearch provides full-text search for articles. It runs as a separate service in the Docker stack and is wired into Laravel through Scout (laravel/scout + meilisearch/meilisearch-php). Meilisearch handles relevance, typo-tolerance, and filtering, so PostgreSQL is no longer queried with ILIKE for search.
Usage
| Feature | Meilisearch Usage | Notes |
|---|---|---|
| Article full-text search | SCOUT_DRIVER=meilisearch | Title, content, excerpt, author, tags |
| Filterable attributes | searchableSettings() | is_active, published_at, category_id, school_id |
| Landing search + filter | Combined in one Meilisearch call | No re-filtering in SQL |
| Indexing | Via Redis queue (SCOUT_QUEUE=true) | Non-blocking writes |
Environment Variables
env
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=...
SCOUT_PREFIX=
SCOUT_QUEUE=trueDocker Compose
yaml
services:
meilisearch:
image: getmeili/meilisearch:v1.52.0
environment:
MEILI_MASTER_KEY: ${MEILISEARCH_KEY}
MEILI_ENV: production
ports:
- "7700:7700"
volumes:
- meilisearch_data:/meili_dataRunning without Docker Compose
bash
docker run -d \
--name sutomo-meilisearch \
-p 7700:7700 \
-v ~/meilisearch/data:/meili_data \
-e MEILI_MASTER_KEY=sutomo-master-key-2026 \
-e MEILI_ENV=development \
getmeili/meilisearch:v1.52.0Model Integration
Article is made searchable via the HasSearchable concern:
php
// app/Models/News/Article/Concerns/HasSearchable.php
public function searchableSettings(): array
{
return [
'filterableAttributes' => [
'is_active',
'published_at',
'category',
'school',
'category_id',
'school_id',
],
];
}Re-sync index settings
After changing searchableSettings(), apply them to the live index:
bash
php artisan articles:sync-search-indexRe-import all articles
bash
php artisan scout:import "App\Models\News\Article\Article"Key Files
| File | Purpose |
|---|---|
config/scout.php | Scout driver, Meilisearch host/key |
app/Models/News/Article/Concerns/HasSearchable.php | Searchable shape + index settings |
app/Console/Commands/SyncArticleSearchIndex.php | Apply filterable attributes |
docker-compose.yml | Meilisearch service definition |
.env | SCOUT_DRIVER, MEILISEARCH_*, SCOUT_QUEUE |