meilisearch:reindex
Reindex content in Meilisearch for maintenance (normal operations use automatic indexing).
Synopsis
Description
This command performs maintenance reindexing of content in Meilisearch. It's used for:
Recovering from index corruption
Applying configuration changes
Periodic maintenance
Troubleshooting search issues
Note: Normal operations use automatic indexing via Eloquent observers. This command is only needed for maintenance and troubleshooting.
Options
--type=TYPE
Specify the type of content to reindex. Available types:
all(default) - Reindex all content typesgames- Reindex only gamesdialogue- Reindex only dialogue textsreviews- Reindex only reviewstags- Reindex only tags
Usage Examples
Full Reindex
Reindex all content:
Output:
Partial Reindex
Reindex only games:
Output:
DDEV Environment
Run reindex in DDEV:
When to Use
Recommended Scenarios
Use meilisearch:reindex when:
Search Results Outdated: Search returns stale or incorrect results
After Configuration Changes: Modified searchable/filterable fields
Index Corruption: Meilisearch index appears corrupted
Periodic Maintenance: Monthly or quarterly maintenance
After Bulk Updates: Large data migrations or bulk updates
Troubleshooting: Diagnosing search issues
Not Needed For
Don't use for normal operations:
â Creating new games (automatic)
â Updating game information (automatic)
â Adding dialogue (automatic)
â Creating reviews (automatic)
â Modifying tags (automatic)
Performance
Execution Time
Content Type | Records | Estimated Time |
|---|---|---|
Games | 10,000 | 2-3 minutes |
Dialogue | 1M+ | 10-15 minutes |
Reviews | 50,000 | 3-5 minutes |
Tags | 500 | < 1 minute |
All | All | 15-25 min |
Resource Usage
CPU: High during reindexing
Memory: Moderate (batched processing)
Disk I/O: Moderate
Network: Low (local Meilisearch)
Optimization
The command uses batched processing to minimize memory usage:
Games: 500 per batch
Dialogue: 1,000 per batch
Reviews: 500 per batch
Tags: 100 per batch
How It Works
1. Validation
Checks that Meilisearch is accessible and indexes exist.
2. Batch Processing
Processes records in batches to avoid memory issues:
3. Progress Tracking
Displays progress during reindexing:
4. Verification
Confirms successful completion and provides statistics.
Automatic Indexing
After reindexing, automatic indexing continues to work:
Model Observers
Eloquent observers handle automatic indexing:
Searchable Models
The following models are automatically indexed:
App\Models\GameApp\Models\UniqueDialogueTextApp\Models\ReviewApp\Models\Tag
Troubleshooting
Reindex Fails
Problem: Reindexing fails with errors
Solutions:
Check Meilisearch is running:
ddev describeVerify database connectivity
Check Meilisearch logs:
ddev logs -s meilisearchTry reindexing specific type:
--type=gamesIncrease PHP memory limit
Slow Performance
Problem: Reindexing is very slow
Solutions:
Run during low-traffic periods
Reindex specific types instead of all
Increase Meilisearch memory allocation
Check database query performance
Verify network connectivity
Memory Issues
Problem: Out of memory errors
Solutions:
Increase PHP memory limit in
php.iniReduce batch size in command code
Reindex one type at a time
Restart PHP-FPM:
ddev restart
Incomplete Reindex
Problem: Some records not reindexed
Solutions:
Check for errors in output
Verify all models are searchable
Check database for orphaned records
Run again with specific type
Check Meilisearch index health
Best Practices
Schedule Maintenance: Run monthly or quarterly
Monitor Performance: Watch search metrics
Low Traffic Periods: Run during off-peak hours
Verify Results: Test search after reindexing
Log Output: Save output for troubleshooting
Backup First: Ensure database backups are current
Monitoring
Check Index Status
Verify index health after reindexing:
Test Search
Verify search works correctly:
Performance Metrics
Monitor search performance in application logs.
Related Commands
meilisearch:setup - Initial Meilisearch setup
scout:sync-index-settings - Sync index configuration