timescale

pg_textsearch: Rank PostgreSQL Search Results with BM25

pg_textsearch is a PostgreSQL extension for BM25 relevance-ranked full-text search, with Block-Max WAND for fast top-k queries. It fits teams that want ranked text search inside PostgreSQL, using its text search configurations and indexes.

View on GitHub Compare
Stars
4k
Forks
130
Stars, last 30 days
+30
Last commit
7 days ago
Contributors
12

Our take

Activeregular commits and releases

Health score

58/100

How it is scored
Activity
69
Community
41
Issues
64
Pull requests
58

+30 stars in the last 30 days

  • Merges more pull requests than 82% of the projects we track
  • Releases more often than 75% of the projects we track

pg_textsearch is an actively maintained PostgreSQL-native BM25 extension with useful ranking and indexing capabilities, but its development is concentrated among a small number of contributors.

Good fit if

  • Your data and application already use PostgreSQL 17 or 18, and you want BM25-ranked results within that database.
  • You need PostgreSQL text configurations, Boolean filters, or expression and partial indexes for search.
  • You can evaluate query plans and account for the documented behavior of ranking with filters and partition-local statistics.

Look elsewhere if

  • You need one globally comparable BM25 score across partitions, since statistics are local to each partition.
  • Your workload depends on Boolean filtering and BM25 ranking being optimized as a single index scan. The README says this combination currently filters, scores matching rows, then sorts.
  • Your team cannot take on the operational implications of a PostgreSQL extension that requires shared preloading and index maintenance.
All health signals
Last commit2026-10-16 (7 days ago)
Commits, last 90 days70
Releases, last 12 months21 (latest v1.5.1, 2026-10-02)
Contributors12 (top contributor: 75% of commits)
Issues closed, last 90 days23+ (typically closed in 6 days)
Pull requests merged, last 90 days72 (typically merged in 1 day)
Project age16 months

Checked on 2026-10-24 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

4,065

Forks

132

Change since Nov 17, 2026: 0 stars·0 forks

Overview

pg_textsearch is a PostgreSQL extension for modern, BM25 relevance-ranked full-text search. It adds a bm25 index access method and a <@> scoring operator, so applications can rank text results directly in PostgreSQL rather than sending search work to a separate service. Block-Max WAND supports fast top-k scans when PostgreSQL chooses an ordered BM25 index scan.

It is aimed at PostgreSQL applications that need configurable relevance ranking alongside familiar database features. The extension supports PostgreSQL text search configurations, Boolean filtering, and several index forms, including expression, partial, and partitioned indexes. It supports PostgreSQL 17 and 18; PostgreSQL 19 is best-effort while in beta.

Key Features

  • BM25 ranking with configurable term-frequency saturation (k1) and length normalization (b).
  • Block-Max WAND for top-k ranking queries using an ordered BM25 index scan.
  • PostgreSQL text search configurations for tokenization and language-specific search.
  • Boolean tsquery filtering, including AND, OR, NOT, phrase, prefix, and weight operators.
  • Expression, partial, and partitioned-table indexes, with explicit query syntax available when index inference is ambiguous.
  • Parallel index builds, compressed segments, and configurable inline, background, or manual compaction.
  • A shared-memory memtable cache with a durable, WAL-logged on-disk source of truth.

Use Cases

  • A PostgreSQL application needs relevance-ranked document search without routing queries to a separate search system.
  • A product catalog or content database needs top-k text results with category or other SQL filtering.
  • An application searches multilingual content and can maintain separate language-specific indexes and text configurations.
  • A team searches text stored in JSONB fields or composed from multiple columns using expression indexes.

What you need

Detected in the repository

  • C (main language on GitHub)
  • A test suite and automated checks on GitHub Actions

License in plain words

PostgreSQL

Read the LICENSE file before using it in a product.

Getting Started

Build and install from source on Linux or macOS:

git clone https://github.com/timescale/pg_textsearch
cd pg_textsearch
make
make install

Add pg_textsearch to shared_preload_libraries in postgresql.conf, restart PostgreSQL, then run CREATE EXTENSION pg_textsearch; in the target database. See the README for package installation, platform-specific instructions, configuration, and upgrade guidance.

Alternatives

  • paradedb: ParadeDB provides PostgreSQL search alongside vector retrieval and analytics, rather than focusing on BM25 ranking with Block-Max WAND.
  • flexsearch: FlexSearch is a JavaScript search library for browsers and Node.js, rather than a PostgreSQL extension using database indexes.
ProjectLanguageLicenseStarsStatus
pg_textsearchCPostgreSQL4kActive
paradedbRustAGPL-3.09.3kActive
flexsearchJavaScriptApache-2.013.8kQuiet

Considerations

  • The extension supports PostgreSQL 17 and 18. PostgreSQL 19 support is best-effort, and the README notes that CI may fail and prebuilt binaries are not published for it yet.
  • shared_preload_libraries must include the extension, and its indexes have operational details around spills, compaction, memory, and standby-safe page reclaim.
  • BM25 statistics for partitioned tables are local to each partition, so scores may not be comparable across partitions.
  • Boolean filtering combined with BM25 ranking is not currently a single optimized index scan. Other conditions on an ordered BM25 scan can also act as post-filters.
  • RLS-protected rows affect corpus statistics, which can reveal frequency information about terms even when rows are hidden. The README documents a superuser-only setting to reject certain RLS and BM25 combinations.
  • Project activity is strong, with regular commits and releases and prompt issue and pull-request handling, but most contributions come from one contributor. The PostgreSQL license is stated as PostgreSQL in the repository metadata.

Found this useful?

Share it with someone who would like pg_textsearch.

Comparisons