jonaspauleta / scout-postgres
Native Postgres full-text search + pg_trgm engine for Laravel Scout.
Requires
- php: ^8.5
- illuminate/contracts: ^13.0
- illuminate/database: ^13.0
- illuminate/support: ^13.0
- laravel/scout: ^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- driftingly/rector-laravel: ^2.2
- larastan/larastan: ^3.0
- laravel/pint: ^1.25
- orchestra/testbench: ^11.0
- pestphp/pest: ^5.0
- pestphp/pest-plugin-laravel: ^5.0
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- rector/rector: ^2.2
README
Native Postgres 18 full-text search + pg_trgm trigram similarity engine for Laravel Scout. Drop-in replacement for Meilisearch on apps running Laravel Cloud (Neon Postgres) or any managed Postgres that allows CREATE EXTENSION pg_trgm and CREATE EXTENSION unaccent.
Requirements
- PHP 8.5+
- Laravel 13+
- Laravel Scout 11+
- Postgres 18
- Extensions:
pg_trgm>= 1.6,unaccent>= 1.1
Install
composer require jonaspauleta/scout-postgres php artisan vendor:publish --tag=scout-postgres-config php artisan migrate
Configure
Set your Scout driver:
SCOUT_DRIVER=pgsql SCOUT_QUEUE=false
SCOUT_QUEUE=false is recommended — generated columns compute on write, so there is nothing to queue.
Make a model searchable
Schema::table('tracks', function (Blueprint $table): void { $table->postgresSearchable(['name' => 'A', 'city' => 'B', 'country' => 'C']); });
On the model:
use Laravel\Scout\Searchable; final class Track extends Model { use Searchable; protected $hidden = ['search_vector', 'search_text']; }
Scout's toSearchableArray() is not required — the engine reads directly from the generated columns.
Query
Track::search('nurb')->take(5)->get(); Track::search('spa')->where('active', true)->paginate(20);
Soft deletes, ->where() with operators, ->whereIn(), ->orderBy(), ->paginate(), ->cursor() all supported.
Per-model overrides
use ApexScout\ScoutPostgres\Contracts\PostgresSearchable; final class Track extends Model implements PostgresSearchable { public function scoutPostgresConfig(): array { return ['trigram_threshold' => 0.25]; } }
Configuration options
See config/scout-postgres.php. Every option is environment-overridable.
License
MIT.