meilisearch:setup
Set up Meilisearch indexes and migrate data from PostgreSQL search.
Synopsis
Description
This command performs the initial setup of Meilisearch for FVN.li, including:
Connection Verification: Checks that Meilisearch is accessible
Index Creation: Creates all required search indexes
Configuration: Applies searchable, filterable, and sortable field settings
Data Migration: Imports existing data from PostgreSQL into Meilisearch
Verification: Confirms successful setup
This is typically run once during initial deployment or when setting up a new environment.
Options
--force
Force reindexing even if indexes already exist.
Use this option to:
Rebuild indexes from scratch
Recover from corrupted indexes
Apply configuration changes that require full reindex
Usage Examples
Initial Setup
Set up Meilisearch on a new environment:
Force Rebuild
Rebuild all indexes from scratch:
DDEV Environment
Run setup in DDEV:
What It Does
1. Connection Check
Verifies that Meilisearch is running and accessible:
If connection fails:
2. Index Setup
Creates and configures the following indexes:
Games Index
Searchable: title, description, author
Filterable: tags, languages, platforms, content_flags, rating, release_date
Sortable: rating, release_date, created_at
Dialogue Index
Searchable: text, character_name
Filterable: game_id, language, character_id
Sortable: created_at
Reviews Index
Searchable: content, title
Filterable: game_id, rating, user_id
Sortable: rating, created_at
Tags Index
Searchable: name, description
Filterable: category, usage_count
Sortable: usage_count, name
3. Data Import
Imports existing data from PostgreSQL:
4. Success Message
Displays helpful information after successful setup:
Prerequisites
Meilisearch Running
Ensure Meilisearch is running before setup:
Environment Configuration
Verify .env settings:
Database Data
Ensure PostgreSQL database is populated with data to import.
Performance
Execution Time
Small dataset (< 1,000 games): 1-2 minutes
Medium dataset (1,000-10,000 games): 5-10 minutes
Large dataset (> 10,000 games): 10-20 minutes
Resource Usage
Memory: Meilisearch uses RAM for indexing
CPU: High during initial import
Disk: Indexes stored on disk after import
Optimization Tips
Run during low traffic: Setup can be resource-intensive
Adequate memory: Ensure Meilisearch has sufficient RAM
Monitor progress: Watch logs for any errors
Verify completion: Check that all data was imported
Troubleshooting
Connection Failed
Problem: Cannot connect to Meilisearch
Solutions:
Check Meilisearch is running:
ddev describeVerify
MEILISEARCH_HOSTin.envCheck Meilisearch logs:
ddev logs -s meilisearchRestart Meilisearch:
ddev restart
Import Timeout
Problem: Import times out for large datasets
Solutions:
Increase PHP timeout in
php.iniRun in smaller batches using
meilisearch:reindex --type=gamesIncrease Meilisearch memory allocation
Run during off-peak hours
Partial Import
Problem: Some data not imported
Solutions:
Check for errors in output
Verify database connectivity
Run with
--forceto retryCheck Meilisearch logs for errors
Index Already Exists
Problem: Indexes already exist
Solutions:
Use
--forceto rebuild:php artisan meilisearch:setup --forceOr manually delete indexes first
Or skip setup if indexes are already configured
Post-Setup
Verify Search Works
Test search functionality:
Check Index Health
Verify indexes are healthy:
Monitor Performance
Watch search performance in application logs and Meilisearch dashboard.
Automatic Indexing
After setup, indexing is automatic:
New records: Indexed immediately on creation
Updates: Re-indexed on save
Deletions: Removed from index on delete
No manual intervention needed for normal operations.
Related Commands
meilisearch:reindex - Reindex content for maintenance
scout:sync-index-settings - Sync index configuration