CLI & Migrations
Use the interactive CLI to set up database indices, generated columns, and apply migrations for pg-smart-search.
CLI & Migrations
Setting up the required PostgreSQL indices and generated columns can be tedious. pg-smart-search provides an interactive CLI to automate this process.
Interactive Setup
Run the init command in your project directory:
npx pg-smart-initThe CLI is a fully interactive wizard (no flags) that prompts you to:
- Enter the table you want to make searchable.
- Enter the columns to search (comma-separated).
- Confirm whether to enable hybrid search (FTS + Trigrams).
- Choose your Search Tier (LITE, STANDARD, ADVANCED, VECTOR).
- Enable or disable Turbo Mode (Generated Columns), if hybrid search is on.
- Choose a cache provider (None / Memory / Redis) and TTL.
At the end it always prints the generated SQL, then separately asks whether to (a) apply
it directly to a database you give it a connection string for, and (b) save it to
search-setup.sql / search-config.js.
There is currently no non-interactive or CI/CD mode. The CLI has no command-line
flags at all -- every step is an enquirer prompt, so it can't run unattended in a
pipeline. For CI/CD, run it once locally and commit the generated search-setup.sql (or
the raw SQL it prints) as a normal migration file.
Generated SQL
The CLI creates indices based on your chosen tier:
- GIN Index: For standard FTS and Trigram searches.
- RUM Index (ADVANCED tier): The wizard emits
CREATE EXTENSION rumand aUSING RUMindex, but this is unverified in practice -- RUM isn't a standard Postgres contrib module and may fail to install, andAdvancedStrategy's real query sortsword_similarity()in memory rather than via a RUM-ordered scan. The index that actually accelerates its<%pre-filter is a plain GiST/GINgist_trgm_ops/gin_trgm_opstrigram index. - HNSW Index: For vector similarity search (if using pgvector).
The generated SQL is always printed to the console before you're asked whether to apply or save it -- there's no separate "output only" mode, reviewing it is just the default.