Laravel Scout
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Analyze existing model and search patterns
- fuse-ai-pilot:research-expert - Verify Scout docs via Context7
- mcp__context7__query-docs - Check search and indexing patterns
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
| Component |
Purpose |
| Searchable Trait |
Makes Eloquent models searchable |
| Search Drivers |
Meilisearch, Algolia, database, collection |
| Indexing |
Automatic sync on model changes |
| Search Builder |
Fluent search API with filters |
Decision Guide: Search Driver
Which driver?
├── Production (recommended) → Meilisearch (fast, self-hosted, free)
├── Managed service → Algolia (hosted, pay per search)
├── Small dataset → database (no extra infra)
└── Testing → collection (in-memory, no engine)
Quick Setup
composer require laravel/scout
composer require meilisearch/meilisearch-php http-interop/http-factory-guzzle
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=masterKey
$results = Article::search('laravel tutorial')->paginate(15);
Critical Rules
- Use
toSearchableArray() to control indexed data
- Queue indexing with
SCOUT_QUEUE=true for performance
- Use
searchable() for bulk import after setup
- Pause indexing during seeders with
Scout::withoutSyncing()
Reference Guide
| Need |
Reference |
| Searchable trait, indexing, conditions |
searchable.md |
| Driver setup, Meilisearch, Algolia |
drivers.md |
Best Practices
DO
- Use Meilisearch for production (fast, typo-tolerant)
- Queue indexing operations (
SCOUT_QUEUE=true)
- Limit indexed fields with
toSearchableArray()
DON'T
- Index sensitive data (passwords, tokens)
- Forget to import existing records after setup
- Use collection driver in production
Laravel 13 Notes
Vector search natif pgvector
Pour la recherche sémantique (embeddings) sur PostgreSQL, Laravel 13 expose Schema::ensureVectorExtensionExists() et whereVectorSimilarTo() via la skill dédiée [[laravel-vector-search]]. Scout reste pertinent pour le full-text (Meilisearch/Algolia) ; pour la similarité vectorielle, utiliser pgvector directement sans driver Scout.
// Hybride : Scout pour full-text, pgvector pour similarité
$keyword = Post::search($query)->get();
$semantic = Post::whereVectorSimilarTo('embedding', $embedding, limit: 10)->get();
1---2name: laravel-scout3description: Implement full-text search with Laravel Scout. Use when adding search to Eloquent models with Meilisearch, Algolia, or database driver.4versions:5 laravel: "13.0"6 scout: "10.12"7 php: "8.3"8user-invocable: false9references: references/searchable.md, references/drivers.md10related-skills: laravel-architecture, laravel-eloquent11metadata:12 source: https://skillmd.com/skills/fusengine/laravel-scout13---1415<objective>16Covers Laravel Scout full-text search: the Searchable trait on Eloquent17models, driver selection (Meilisearch, Algolia, database, collection),18automatic index sync on model changes, the fluent search builder with19filters, toSearchableArray() field control, queued indexing, and bulk20import/reindexing. For semantic/vector similarity search on PostgreSQL, see21laravel-vector-search instead — Scout stays the tool for keyword/full-text22search.23</objective>2425# Laravel Scout2627## Agent Workflow (MANDATORY)2829Before ANY implementation, spawn 3 agents in parallel, one `Agent` call each with a `name`:30311. **fuse-ai-pilot:explore-codebase** - Analyze existing model and search patterns322. **fuse-ai-pilot:research-expert** - Verify Scout docs via Context7333. **mcp__context7__query-docs** - Check search and indexing patterns3435After implementation, run **fuse-ai-pilot:sniper** for validation.3637---3839## Overview4041| Component | Purpose |42|-----------|---------|43| **Searchable Trait** | Makes Eloquent models searchable |44| **Search Drivers** | Meilisearch, Algolia, database, collection |45| **Indexing** | Automatic sync on model changes |46| **Search Builder** | Fluent search API with filters |4748---4950## Decision Guide: Search Driver5152```53Which driver?54├── Production (recommended) → Meilisearch (fast, self-hosted, free)55├── Managed service → Algolia (hosted, pay per search)56├── Small dataset → database (no extra infra)57└── Testing → collection (in-memory, no engine)58```5960---6162## Quick Setup6364```bash65composer require laravel/scout66composer require meilisearch/meilisearch-php http-interop/http-factory-guzzle67```6869```env70SCOUT_DRIVER=meilisearch71MEILISEARCH_HOST=http://127.0.0.1:770072MEILISEARCH_KEY=masterKey73```7475```php76$results = Article::search('laravel tutorial')->paginate(15);77```7879---8081## Critical Rules82831. **Use `toSearchableArray()`** to control indexed data842. **Queue indexing** with `SCOUT_QUEUE=true` for performance853. **Use `searchable()`** for bulk import after setup864. **Pause indexing** during seeders with `Scout::withoutSyncing()`8788---8990## Reference Guide9192| Need | Reference |93|------|-----------|94| Searchable trait, indexing, conditions | [searchable.md](references/searchable.md) |95| Driver setup, Meilisearch, Algolia | [drivers.md](references/drivers.md) |9697---9899## Best Practices100101### DO102- Use Meilisearch for production (fast, typo-tolerant)103- Queue indexing operations (`SCOUT_QUEUE=true`)104- Limit indexed fields with `toSearchableArray()`105106### DON'T107- Index sensitive data (passwords, tokens)108- Forget to import existing records after setup109- Use collection driver in production110111---112113## Laravel 13 Notes114115### Vector search natif pgvector116Pour la recherche sémantique (embeddings) sur PostgreSQL, Laravel 13 expose `Schema::ensureVectorExtensionExists()` et `whereVectorSimilarTo()` via la skill dédiée [[laravel-vector-search]]. Scout reste pertinent pour le full-text (Meilisearch/Algolia) ; pour la similarité vectorielle, utiliser pgvector directement sans driver Scout.117118```php119// Hybride : Scout pour full-text, pgvector pour similarité120$keyword = Post::search($query)->get();121$semantic = Post::whereVectorSimilarTo('embedding', $embedding, limit: 10)->get();122```