Skip to content

Latest commit

 

History

History
91 lines (57 loc) · 2.74 KB

File metadata and controls

91 lines (57 loc) · 2.74 KB

Examples

Self-contained scripts that show how to use ParadeDB from Drizzle. Run them all with pnpm examples, or follow the setup below and run them one at a time.

Getting Started

1. Install dependencies

# Install pnpm: https://pnpm.io/installation
pnpm install

2. Start ParadeDB

pnpm db:setup

This starts a ParadeDB container via Docker and exports DATABASE_URL. If you already have a Postgres instance with ParadeDB installed, set DATABASE_URL yourself instead:

export DATABASE_URL=postgresql://user:password@localhost:5432/dbname

Quickstart (quickstart.ts)

The "Hello World" of ParadeDB. Covers declaring a ParadeDB index on a table, running keyword queries, sorting by BM25 relevance, and highlighting matched terms in snippets.

pnpm examples quickstart.ts

Vector Search (vector-search.ts)

Top-K nearest-neighbor retrieval over pgvector vector columns. ParadeDB indexes the vector column inside its search index, so one index serves both keyword and vector queries.

Requires the pgvector extension, which is included in the ParadeDB Docker image.

pnpm examples vector-search.ts

Faceted Search (faceted-search.ts)

Builds an e-commerce-style filter sidebar. Computes search results and facet counts (by category, rating, and so on) together in a single query.

pnpm examples faceted-search.ts

Hybrid Search (RRF) (hybrid-rrf.ts)

Combines BM25 keyword search (good for exact matches like part numbers) with vector similarity (good for meaning) using Reciprocal Rank Fusion, which ranks better than either method alone.

Requires the pgvector extension, which is included in the ParadeDB Docker image.

pnpm examples hybrid-rrf.ts

Retrieval-Augmented Generation (RAG) (rag.ts)

A small question-answering flow. Retrieves relevant context with ParadeDB, then sends it to an LLM so answers are grounded in your own data.

Retrieval runs without any configuration. Set an OpenRouter API key to enable the generation step:

export OPENROUTER_API_KEY=sk-...
pnpm examples rag.ts

Autocomplete (autocomplete.ts)

As-you-type suggestions using n-gram tokenization, which matches substrings in the middle of words — typing wir matches wireless.

pnpm examples autocomplete.ts

More Like This (more-like-this.ts)

"Related content" recommendations. Finds documents with similar keywords using TF-IDF logic, without requiring vector embeddings.

pnpm examples more-like-this.ts

Shared Helpers (common.ts)

Most examples import from examples/common.ts, which keeps the boilerplate out of the example scripts: it opens the connection, defines the demo table, and seeds it with data.