pg_textsearch
pg_textsearch · Full-text search with BM25 ranking
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2190 | pg_textsearch | pg_textsearch | 1.6.0 | FTS | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| See Also | pg_search pg_bestmatch vchord_bm25 pg_fts pgroonga pg_rrf psql_bm25s pgcontext vectorize |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PGDG 1.6.0 | PGDG 1.6.0 | N/A | N/A |
| el8.aarch64 | N/A | PGDG 1.6.0 | PGDG 1.6.0 | N/A | N/A |
| el9.x86_64 | PGDG 1.6.0 | PGDG 1.6.0 | PGDG 1.6.0 | N/A | N/A |
| el9.aarch64 | PGDG 1.6.0 | PGDG 1.6.0 | PGDG 1.6.0 | N/A | N/A |
| el10.x86_64 | PGDG 1.6.0 | PGDG 1.6.0 | PGDG 1.6.0 | N/A | N/A |
| el10.aarch64 | PGDG 1.6.0 | PGDG 1.6.0 | PGDG 1.6.0 | N/A | N/A |
| d12.x86_64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| d12.aarch64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| d13.x86_64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| d13.aarch64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| u22.x86_64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| u22.aarch64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| u24.x86_64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| u24.aarch64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| u26.x86_64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
| u26.aarch64 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | PIGSTY 1.6.0 | N/A | N/A |
Source
github.com/timescale/pg_textsearch
pg_textsearch-1.6.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources:
pg_textsearch 1.6.1 provides BM25-ranked text search on PostgreSQL 17–19 through the bm25 access method and <@> operator.
Enable and Query
An administrator must add the library to the existing preload list and restart PostgreSQL. Installation requires elevated privileges.
Scores are negative BM25 values: lower values rank first. Use an explicit index for partial indexes, ambiguous expressions, prepared or dynamic query text, and PL/pgSQL. Standalone scoring needs SELECT permission on the indexed table or columns.
Filtering and Index Options
text_config is required; k1 defaults to 1.2 and b to 0.75. Immutable text expressions, text-like arrays, partial indexes and partitioned tables are supported. Repeat indexed expressions in queries and supply a matching predicate for partial indexes. A parser such as zhparser is an optional dependency for Chinese text.
Boolean queries support AND/OR/NOT, phrases, prefixes and weights. Phrase and weight checks can require table-row rechecks. The text-search configuration must match the index. If it changes while using a cached Boolean plan, deallocate and prepare the statement again.
In 1.6.0, eligible constant Boolean predicates run inside ranked scans when every match is guaranteed to contain a ranking term. Other forms, including generic plans with unknown terms, retain PostgreSQL filtering and sorting. Post-filtered ranked scans expand their scoring batch until enough rows qualify or matches run out. Inspect EXPLAIN; a small LIMIT does not guarantee little work.
Maintenance and Boundaries
The durable memtable lives in WAL-logged index pages. Shared-memory caching is optional; pg_textsearch.memory_limit defaults to 2GB and is an approximate admission budget, not a hard bound. pg_textsearch.default_limit defaults to 1000 and sets the initial batch when no SQL limit is available. Spills and serial VACUUM can perform synchronous compaction.
Mutating maintenance functions require index ownership and do not operate on partitioned parent indexes or during recovery. Published physical merges are not undone by ROLLBACK. Optional managed background compaction has additional upstream setup requirements; inline/manual modes do not require it. Querying hot standbys need hot_standby_feedback = on to delay physical page reuse for active snapshots.
The bm25 access-method name conflicts with other providers such as pg_search and vchord_bm25. RLS hides rows but BM25 corpus statistics still reflect all indexed rows. Superusers can set pg_textsearch.allow_rls to off to reject new or rebuilt combinations with RLS; this does not disable existing indexes.
Upgrade to 1.6.1
Install matching libraries and SQL files, restart PostgreSQL, then update every database:
Version 1.6.1 fixes score reuse with ordered scans, correlated filters and RLS, standalone scoring during concurrent VACUUM, and parallel builds of partial expression indexes. Upgrading from 1.6.0 requires no REINDEX. The following repair guidance concerns older affected indexes. Earlier parallel builds involving HOT chains could omit rows, and interrupted VACUUM could leave incorrect counts or bitmaps. Rebuild affected indexes; upgrading binaries and SQL cannot repair their contents.
Standard REINDEX blocks writes. Check all intervening upgrade notes for older indexes: pre-1.3 unspilled data needs handling under the old binary, pre-1.5 indexes can omit empty or stopword-only documents from negative Boolean queries, and version-9 headers cannot be read by pre-1.5 servers. Upgrade replicas before new binaries modify index headers; a binary downgrade does not reverse that change.