SyntaxStudy
Sign Up
MySQL Full-Text Search in Laravel
MySQL Intermediate 4 min read

Full-Text Search in Laravel

Full-Text in Laravel

Laravel supports full-text search via whereFullText() in Eloquent queries and fullText() in migrations.

Example
// Migration
$table->fullText(['title', 'body']);

// Eloquent query
Article::whereFullText(['title', 'body'], 'mysql performance')->get();

// With options
Article::whereFullText(['title', 'body'], '+mysql -oracle', [
    'mode' => 'boolean',
])->get();
Pro Tip

Laravel's whereFullText maps directly to MATCH AGAINST under the hood.