Quick Start
Set up pg-smart-search in 3 minutes. Install the package, run the interactive CLI, and execute your first search.
Quick Start
Get typo-tolerant, parallel search running in your PostgreSQL database in three steps. (Actual latency depends on your dataset and hardware — see Benchmarks.)
Step 1: Install the package
$npm install pg-smart-searchStep 2: Initialize your database
The CLI will automatically create the required indices and generated columns for your dataset.
npx pg-smart-initFollow the interactive prompts to select your table, columns, and search tier.
Migrations in CI/CD? The CLI is fully interactive with no flags and no
non-interactive mode — it can't run unattended in a pipeline today. Run it once locally
and commit the generated search-setup.sql as a normal migration instead. See CLI &
Migrations.
Step 3: Implement the Search Engine
import { TrigramSearchEngine, MemoryCacheProvider } from "pg-smart-search";
// Wrap your own pg.Pool (or Prisma/Drizzle/etc.) in a 3-method DatabaseAdapter --
// see /docs/guides/configuration for the interface and a minimal example.
const adapter = yourDbAdapter;
const engine = new TrigramSearchEngine(adapter, {
tableName: "products",
searchColumns: ["name", "description"],
ftsColumn: "search_vector", // Enabled via Turbo Mode (AOT)
cacheProvider: new MemoryCacheProvider(),
defaultTTL: 3600,
});
// Execute search with typo tolerance ("laptpp" instead of "laptop")
const results = await engine.search({
query: "laptpp",
language: "en",
});
console.log(results);Next Steps
- Learn how Parallel Fast-Track achieves low latency.
- Configure Redis Caching for distributed environments.
Installation
How to install pg-smart-search in your Node.js or TypeScript project using npm, yarn, or pnpm.
Architecture & Parallel Fast-Track
Deep dive into how pg-smart-search executes queries concurrently and cancels zombie queries. Actual latency depends on your hardware and dataset — see Benchmarks.