Skip to content
Skill

Postgres hybrid text search

Guides building hybrid BM25 and vector search in PostgreSQL with RRF fusion

Postgres hybrid text search is an open-source agent skill for knowledge and memory. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
1.9K
Last commit
License
Apache-2.0
Listing updated

Similar skills

About Postgres hybrid text search

This skill walks an agent through combining BM25 keyword ranking from pg_textsearch with semantic nearest-neighbour search from pgvector inside one PostgreSQL database. It supplies a default schema with a BM25 index on text and an HNSW index on halfvec embeddings, plus the operator patterns for each search type.

The core technique is client-side Reciprocal Rank Fusion. The agent runs the keyword and semantic queries in parallel, then merges the two ranked lists with a rank-based score, and the skill includes Python and TypeScript fusion functions. It also covers weighting one method above the other, tuning candidate pool sizes, and an optional cross-encoder or hosted reranker pass over a larger candidate set. Guidance on pgvectorscale's DiskANN index with label filtering is included for large or filtered datasets.

The skill expects PostgreSQL 15 or newer with the pgvector and pg_textsearch extensions, and chunked documents stored with their embeddings. It also includes EXPLAIN checks and a short troubleshooting table for missing exact matches and skewed results. The source notes that pg_textsearch is in prerelease and not yet recommended for production.

When your agent uses it

Use this skill to implement hybrid search combining BM25 keyword search with semantic vector search using Reciprocal Rank Fusion (RRF). **Trigger when user asks to:** - Combine keyword and semantic search - Implement hybrid search or multi-modal retrieval - Use BM25/pg_textsearch with pgvector together - Implement RRF (Reciprocal Rank Fusion) for search - Build search that handles both exact terms and meaning **Keywords:** hybrid search, BM25, pg_textsearch, RRF, reciprocal rank fusion, keyword search, full-text search, reranking, cross-encoder Covers: pg_textsearch BM25 index setup, parallel query patterns, client-side RRF fusion (Python/TypeScript), weighting strategies, and optional ML reranking.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 1 file (12 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the pg plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add timescale/pg-aiguide
/plugin install pg@aiguide

Or copy only this skill to ~/.claude/skills/postgres-hybrid-text-search:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/postgres-hybrid-text-search &&
cp -R "$tmp/skills/postgres-hybrid-text-search" ~/.claude/skills/postgres-hybrid-text-search &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/postgres-hybrid-text-search inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/postgres-hybrid-text-search to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/postgres-hybrid-text-search &&
cp -R "$tmp/skills/postgres-hybrid-text-search" ~/.agents/skills/postgres-hybrid-text-search &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/postgres-hybrid-text-search inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/postgres-hybrid-text-search to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/postgres-hybrid-text-search &&
cp -R "$tmp/skills/postgres-hybrid-text-search" ~/.cursor/skills/postgres-hybrid-text-search &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/postgres-hybrid-text-search inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/timescale/pg-aiguide.git --path skills/postgres-hybrid-text-search

Or copy the folder to ~/.gemini/skills/postgres-hybrid-text-search yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/postgres-hybrid-text-search:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/postgres-hybrid-text-search &&
cp -R "$tmp/skills/postgres-hybrid-text-search" ~/.copilot/skills/postgres-hybrid-text-search &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/postgres-hybrid-text-search inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/timescale/pg-aiguide.git

Then copy pg-aiguide/skills/postgres-hybrid-text-search into your agent's skills folder as postgres-hybrid-text-search. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

BM25 index setup
Creates a keyword index on text content with a configurable language and BM25 tuning options.
Parallel keyword and vector queries
Runs BM25 and pgvector searches as separate queries that can be issued concurrently from the client.
RRF fusion code
Provides Python and TypeScript functions that merge two ranked result lists using reciprocal rank scores.
Weighting strategies
Shows how to favour keyword or semantic results by scaling each method's contribution.
Optional reranking step
Describes adding a cross-encoder or hosted reranker over a larger fused candidate set.
Filtered vector search
Covers pgvectorscale DiskANN indexes with smallint label arrays for filtered semantic queries.
Index verification and troubleshooting
Explains how to confirm index use with EXPLAIN and fix common relevance and latency problems.

Good for

  • Add hybrid keyword and semantic search to a PostgreSQL-backed document store
  • Fuse BM25 and pgvector results into one ranked list with RRF
  • Make product code or SKU lookups work alongside meaning-based queries
  • Tune the balance between keyword and semantic results in a search API
  • Add a reranking stage over search candidates

Postgres hybrid text search FAQ

What does the skill need to run?

It requires PostgreSQL 15 or newer with the pgvector and pg_textsearch extensions. The guide notes that pg_textsearch currently supports PostgreSQL 17 and 18.

Does Postgres hybrid text search change my database?

The guidance includes SQL to create extensions, tables and indexes, but the skill itself only instructs the agent on how to build the setup.

Is pg_textsearch ready for production?

The skill states that pg_textsearch is in prerelease and not yet recommended for production use.

Which languages are covered for the fusion code?

The skill includes client-side RRF examples in Python and TypeScript.

Is reranking required?

No. The skill describes reranking as optional, and says RRF alone already improves on single-method search.

How do I install Postgres hybrid text search in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/postgres-hybrid-text-search to use it in all your projects, or to .claude/skills/postgres-hybrid-text-search in one project. Or install the pg plugin, which includes it: /plugin marketplace add timescale/pg-aiguide, then /plugin install pg@aiguide.

Does Postgres hybrid text search run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Postgres hybrid text search?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Postgres hybrid text search?

The closest alternatives to Postgres hybrid text search are Pgvector semantic search, Qdrant hybrid search, Qdrant hybrid search prefetches, Qdrant hybrid search combining and Qdrant edge.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from timescale/pg-aiguide

  1. Guides an agent in designing PostGIS spatial tables, types, SRIDs and indexes

    • Open source
    • 1.9K GitHub stars
    • Databases
  2. Guides an agent through PostgreSQL table design, types, constraints and indexing

    • Open source
    • 1.9K GitHub stars
    • Databases
  3. Scores existing PostgreSQL tables to find which should become TimescaleDB hypertables

    • Open source
    • 1.9K GitHub stars
    • Databases
  4. Guides an agent through pgvector setup, HNSW indexing and tuning for semantic search

    • Open source
    • 1.9K GitHub stars
    • Databases
  5. Guides an agent through PostgreSQL schema design, indexing, search, TimescaleDB

    • Open source
    • 1.9K GitHub stars
    • Databases