SwiftSearch
Open Sky Commerce ships with SwiftSearch — a built-in, zero-configuration full-text search engine powered by PostgreSQL. No third-party account, no API key, and no monthly bill required.
How It Works
SwiftSearch uses two complementary Postgres features to deliver fast, relevant results:
- Full-text search (
to_tsvector/to_tsquery) — ranks results by relevance across product title, description, and category fields. - Trigram similarity (
pg_trgmextension) — catches typos and partial matches so customers still find what they are looking for even when the spelling is off.
Queries run directly against your existing database — there is no separate index to maintain or sync.
Setup
SwiftSearch requires the pg_trgm extension, which is enabled automatically by the included Prisma migration. If you are connecting to an existing database, run:
npx prisma migrate deployNo environment variables are needed for search. It works out of the box as long as DATABASE_URL is set.
Search API
The storefront search bar hits the internal API route at GET /api/search?q=your+query. Results are returned as JSON and include product title, slug, image, price, and category.
Performance
For stores with thousands of products, add a GIN index on the tsvector column and a trigram index on the title column to keep queries fast:
-- Run once on your production database
CREATE INDEX CONCURRENTLY products_fts_idx
ON "Product" USING GIN (to_tsvector('english', title || ' ' || COALESCE(description, '')));
CREATE INDEX CONCURRENTLY products_trgm_idx
ON "Product" USING GIN (title gin_trgm_ops);Extending Search
The search query logic lives in src/app/api/search/route.ts. You can extend it to include additional models (e.g. blog posts, categories) or adjust the ranking weights without any external dependencies.