Skip to content

tsp_semantic_headline

Phrase highlighting and improved semantics for ts_headline

tsp_semantic_headline · Phrase highlighting and improved semantics for ts_headline

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101193tsp_semantic_headlinetsp_semantic_headline1.0FTSGPL-3.0SQL

PostgreSQL · 14, 15, 16, 17, 18

Relationships
Requiresunaccent

Usage

Sources:

tsp_semantic_headline is a pure-SQL experiment for phrase-aware full-text highlighting. It supplies TS_SEMANTIC_HEADLINE, preprocessed query/vector helpers, and TS_FAST_HEADLINE, which can use aligned precomputed TSVECTOR and text[] columns for faster recall.

CREATE EXTENSION unaccent;
CREATE EXTENSION tsp_semantic_headline;
SELECT TS_SEMANTIC_HEADLINE(
  'english',
  'phrase matches are highlighted as complete phrases',
  TO_TSPQUERY('english', 'phrase<->match')
);

Use the same preprocessing for indexed text, recall arrays, and queries; otherwise token positions diverge and highlights are wrong. The fast path trades extra stored columns and update work for lower runtime cost. Reproduce performance claims with your language, corpus, query shapes, and options.

Upstream calls the project in development and documents unimplemented options. Its special-character treatment inserts separators and explicitly warns that space-based assumptions can change or destroy meaning in many languages. Treat highlighted output as presentation, escape it for the destination UI, and never mark untrusted HTML as safe. Test stemming, negation, phrase distance, punctuation, Unicode, XSS, long documents, and divergence after content updates.

Table reader