tsexact
tsexact · Full-text-search helpers for exact phrase matching on PostgreSQL 9.5 and earlier.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100111 | tsexact | tsexact | 1.0 | FTS | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
tsexact 1.0 adds exact-fragment helpers for PostgreSQL full-text vectors. It was designed to emulate phrase search on PostgreSQL 9.5 and earlier; upstream recommends built-in phrase-search operators on PostgreSQL 9.6 and later.
Core Workflow
ts_exact_match(tsvector, tsvector) checks whether the fragment’s relative positions occur at some offset in the document and ignores weights. Its three-argument overload accepts a weight mask for the document. ts_squeeze(tsvector) removes gaps in position numbering, setweight(tsquery, text) applies weights to query lexemes, and poslen(tsvector) returns the total position span.
Indexing Pattern and Caveats
ts_exact_match is not directly supported by full-text indexes. Use an indexed @@ condition to obtain candidates, then apply ts_exact_match as an exact recheck.
Tokenization, dictionaries, stop words, weights, and position gaps all affect results. Prefer native phrase queries on current PostgreSQL, and retain tsexact only when its legacy vector semantics are specifically required and covered by regression tests.