pmatseykanets/laravel-scout-postgres
A PostgreSQL full-text search driver for Laravel Scout. Index Eloquent models with native tsvector and GIN indexes, run ranked searches, and paginate results using PostgreSQL's built-in search capabilities instead of external services.
Architecture fit
Laravel\Scout\Engines\Engine on top of PostgreSQL native full-text search (tsvector, tsquery, ts_rank, GIN indexes). Architecturally it removes an entire hop: no Algolia/Meilisearch/Typesense cluster, no scout:import/queue-sync pipeline, no dual-write consistency problem. Searchable data is derived inside the same transactional store as the source rows.ts_rank-based and dictionary-driven. Language configuration, stopwords, and stemming become product decisions that live in migrations, not in a managed search console — a real difference in who owns relevance tuning.where() constraints and existing scopes still apply. That is a significant simplicity win versus external engines, which require replicating filterable attributes.Integration feasibility
tsvector column (generated column on PG12+ or trigger-maintained), GIN index, backfill, set SCOUT_DRIVER=postgres. One model can be piloted in a day; a whole domain in a sprint.setweight A/B/C/D), dictionary, and index build strategy on large tables (build GIN concurrently, off-peak).Technical risk
Engine contract has changed (e.g. mapIds, lazyMap, paginate signatures, PHP 8.1+ type requirements). Expect to vendor/fork and patch method signatures as part of adoption, not as an afterthought.tsvector has a hard 1 MB limit; oversized documents truncate silently and become partially unsearchable. Needs a guardrail on indexed text length.Key questions
tsvector columns?Stack fit
Migration path
LIKE/ILIKE queries — replace with Scout calls, gaining ranking and index-backed performance; (c) database Scout driver — like-for-like swap with better relevance.SCOUT_DRIVER per environment → pilot one model → expand model by model.scout:import jobs when the external engine is dropped, otherwise dead jobs accumulate.Compatibility
Engine implementation if signatures have drifted. Do not assume the 2021 release works on current Laravel.pg_trgm availability if prefix/substring matching is required alongside FTS.paginate, take, raw, and where callbacks against the engine — these are the interfaces most likely to have shifted between Scout majors.Sequencing
websearch_to_tsquery/plainto_tsquery, never raw to_tsquery on user input).Maintenance
Support
EXPLAIN ANALYZE, understanding GIN index behavior, and diagnosing slow ranked queries — that is a DBA-ish competency the team should have or borrow.Scaling
VACUUM/REINDEX care.Failure modes
tsvector 1 MB cap → silently unsearchable fields; needs a length guardrail and monitoring.to_tsquery → syntax errors surfaced as 500s; use websearch_to_tsquery.Ramp-up
TPM verdict: This is a high-leverage, low-blast-radius simplification for a Postgres-backed Laravel app whose search needs are "find the right row," not "beat Algolia." The dominant risk is not technical but organizational — an unmaintained 2021 package requires a named internal owner and an explicit fork budget before adoption. Approve as a spike-and-fork initiative, not as an unqualified dependency drop-in.
How can I help you explore Laravel packages today?