pg_textsearch
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_textsearch | 1.2.0 | FTS | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2180 | pg_textsearch | No | Yes | Yes | Yes | No | No | - |
bm25 am conflicts with pg_search and vchord_bm25
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.2.0 | 1817161514 | pg_textsearch | - |
| RPM | PIGSTY | 1.2.0 | 1817161514 | pg_textsearch_$v | - |
| DEB | PIGSTY | 1.2.0 | 1817161514 | postgresql-$v-textsearch | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.2.0 el8.x86_64.pg18 : pg_textsearch_18 pg_textsearch_18-1.2.0-1PIGSTY.el8.x86_64.rpm
| PIGSTY 1.2.0 el8.x86_64.pg17 : pg_textsearch_17 pg_textsearch_17-1.2.0-1PIGSTY.el8.x86_64.rpm
| N/A | N/A | N/A |
| el8.aarch64 | PIGSTY 1.2.0 el8.aarch64.pg18 : pg_textsearch_18 pg_textsearch_18-1.2.0-1PIGSTY.el8.aarch64.rpm
| PIGSTY 1.2.0 el8.aarch64.pg17 : pg_textsearch_17 pg_textsearch_17-1.2.0-1PIGSTY.el8.aarch64.rpm
| N/A | N/A | N/A |
| el9.x86_64 | PIGSTY 1.2.0 el9.x86_64.pg18 : pg_textsearch_18 pg_textsearch_18-1.2.0-1PIGSTY.el9.x86_64.rpm
| PIGSTY 1.2.0 el9.x86_64.pg17 : pg_textsearch_17 pg_textsearch_17-1.2.0-1PIGSTY.el9.x86_64.rpm
| N/A | N/A | N/A |
| el9.aarch64 | PIGSTY 1.2.0 el9.aarch64.pg18 : pg_textsearch_18 pg_textsearch_18-1.2.0-1PIGSTY.el9.aarch64.rpm
| PIGSTY 1.2.0 el9.aarch64.pg17 : pg_textsearch_17 pg_textsearch_17-1.2.0-1PIGSTY.el9.aarch64.rpm
| N/A | N/A | N/A |
| el10.x86_64 | PIGSTY 1.2.0 el10.x86_64.pg18 : pg_textsearch_18 pg_textsearch_18-1.2.0-1PIGSTY.el10.x86_64.rpm
| PIGSTY 1.2.0 el10.x86_64.pg17 : pg_textsearch_17 pg_textsearch_17-1.2.0-1PIGSTY.el10.x86_64.rpm
| N/A | N/A | N/A |
| el10.aarch64 | PIGSTY 1.2.0 el10.aarch64.pg18 : pg_textsearch_18 pg_textsearch_18-1.2.0-1PIGSTY.el10.aarch64.rpm
| PIGSTY 1.2.0 el10.aarch64.pg17 : pg_textsearch_17 pg_textsearch_17-1.2.0-1PIGSTY.el10.aarch64.rpm
| N/A | N/A | N/A |
| d12.x86_64 | PIGSTY 1.2.0 d12.x86_64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~bookworm_amd64.deb
| PIGSTY 1.2.0 d12.x86_64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~bookworm_amd64.deb
| N/A | N/A | N/A |
| d12.aarch64 | PIGSTY 1.2.0 d12.aarch64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~bookworm_arm64.deb
| PIGSTY 1.2.0 d12.aarch64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~bookworm_arm64.deb
| N/A | N/A | N/A |
| d13.x86_64 | PIGSTY 1.2.0 d13.x86_64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~trixie_amd64.deb
| PIGSTY 1.2.0 d13.x86_64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~trixie_amd64.deb
| N/A | N/A | N/A |
| d13.aarch64 | PIGSTY 1.2.0 d13.aarch64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~trixie_arm64.deb
| PIGSTY 1.2.0 d13.aarch64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~trixie_arm64.deb
| N/A | N/A | N/A |
| u22.x86_64 | PIGSTY 1.2.0 u22.x86_64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~jammy_amd64.deb
| PIGSTY 1.2.0 u22.x86_64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~jammy_amd64.deb
| N/A | N/A | N/A |
| u22.aarch64 | PIGSTY 1.2.0 u22.aarch64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~jammy_arm64.deb
| PIGSTY 1.2.0 u22.aarch64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~jammy_arm64.deb
| N/A | N/A | N/A |
| u24.x86_64 | PIGSTY 1.2.0 u24.x86_64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~noble_amd64.deb
| PIGSTY 1.2.0 u24.x86_64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~noble_amd64.deb
| N/A | N/A | N/A |
| u24.aarch64 | PIGSTY 1.2.0 u24.aarch64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~noble_arm64.deb
| PIGSTY 1.2.0 u24.aarch64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~noble_arm64.deb
| N/A | N/A | N/A |
| u26.x86_64 | PIGSTY 1.2.0 u26.x86_64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~resolute_amd64.deb
| PIGSTY 1.2.0 u26.x86_64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~resolute_amd64.deb
| N/A | N/A | N/A |
| u26.aarch64 | PIGSTY 1.2.0 u26.aarch64.pg18 : postgresql-18-textsearch postgresql-18-textsearch_1.2.0-1PIGSTY~resolute_arm64.deb
| PIGSTY 1.2.0 u26.aarch64.pg17 : postgresql-17-textsearch postgresql-17-textsearch_1.2.0-1PIGSTY~resolute_arm64.deb
| N/A | N/A | N/A |
Build
You can build the RPM / DEB packages for pg_textsearch using pig build:
Install
You can install pg_textsearch directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
Sources: README v1.2.0, v1.2.0 release notes
pg_textsearch provides BM25-ranked full-text search for PostgreSQL with a bm25 access method and the <@> scoring operator. Upstream marks v1.2.0 as production ready.
v1.2.0 supports PostgreSQL 17 and 18. Prebuilt release assets are published for both PostgreSQL versions on Linux and macOS. The extension must be loaded through shared_preload_libraries before CREATE EXTENSION.
Enable the Extension
Install the new binary and restart PostgreSQL before running an extension upgrade:
The v1.2.0 release adds physical replication support and correctness fixes for update-heavy workloads. Install the matching binary and run the SQL extension upgrade before relying on the new version.
Build and Query BM25 Indexes
<@> returns the negative BM25 score because PostgreSQL operator index scans are ascending; lower values are better matches. Use ORDER BY ... LIMIT for fast top-k searches.
For an explicit index reference, use to_bm25query():
The main documented SQL surface is:
text <@> 'query'to score text with planner-detected index context.text <@> bm25queryto score with an explicitbm25query.to_bm25query(text)for ORDER BY use with planner-selected index context.to_bm25query(text, text)for query text plus index name.bm25query = bm25queryfor equality checks.
Index Options and Data Shapes
Index options are text_config (required), k1 (default 1.2), and b (default 0.75). Text search configurations such as english, simple, french, and german use PostgreSQL text search configuration names.
The extension supports native array input for text[], varchar[], and bpchar[] columns; array elements are concatenated before tokenization.
Expression indexes support immutable text expressions, including JSONB extraction, text transformations, and multi-column concatenation:
Partial indexes scope search to a subset of rows. Query them with an explicit index name:
Operations and GUCs
bm25_force_merge(index_name) consolidates all segments into one and is best used after bulk loads, not during steady write traffic. bm25_memory_usage() reports shared memory usage for memtables.
Documented pg_textsearch GUCs in v1.2.0 include:
pg_textsearch.default_limitpg_textsearch.compress_segmentspg_textsearch.segments_per_levelpg_textsearch.memory_limitpg_textsearch.bulk_load_thresholdpg_textsearch.memtable_spill_threshold(deprecated; usememory_limitfor new deployments)
pg_textsearch.memory_limit defaults to 2GB and caps dynamic shared memory used by memtables. The README also documents bm25_spill_index(index_name), bm25_dump_index(index_name), and bm25_summarize_index(index_name) as development or diagnostic helpers.
Caveats
pg_textsearchrequiresshared_preload_libraries = 'pg_textsearch'and a PostgreSQL restart beforeCREATE EXTENSION.- The
bm25access method name conflicts withpg_searchandvchord_bm25; avoid installing those BM25 access-method extensions into the same database. - Inside PL/pgSQL and stored procedures, the implicit
text <@> 'query'form does not use planner hooks; upstream says to useto_bm25query()with an explicit index name there. - Phrase queries are not native because the index stores term frequencies, not term positions; use BM25 ranking plus a post-filter for phrase-like matching.
- Partial indexes require
to_bm25query()with the index name because the implicit query form skips them. - BM25 indexes on partitioned tables use partition-local statistics, so cross-partition scores may not be directly comparable.
- Words longer than PostgreSQL’s
tsvectorword length limit are ignored during tokenization. pg_textsearchuses fixed LWLock tranche IDs 1001-1008; another extension using the same fixed IDs can make wait-event names inaccurate.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)