Skip to content

tsearch_extras

Full-text-search helpers for returning match locations and extracting tsvector lexemes.

tsearch_extras · Full-text-search helpers for returning match locations and extracting tsvector lexemes.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100407tsearch_extrastsearch_extras1.0FTSPostgreSQLC

PostgreSQL · 10, 11

Usage

Sources:

tsearch_extras version 1.0 exposes lower-level information from PostgreSQL full-text search: locations and lengths of query matches in source text, and the lexemes stored in a tsvector.

Core Workflow

CREATE EXTENSION tsearch_extras;

SELECT ts_match_locs_array(
  'The quick brown fox jumped. The jumping continued.',
  plainto_tsquery('jump')
);

SELECT tsvector_lexemes(
  to_tsvector('The quick brown fox jumped over the lazy dog')
);

Use an explicit text-search configuration when results must not depend on the session default:

SELECT ts_match_locs_array(
  'english'::regconfig,
  'The quick brown fox jumped.',
  plainto_tsquery('english', 'jump')
);

Objects

  • ts_match_locs_array(text, tsquery) returns int4[][2]: match location/length pairs using the current text-search configuration.
  • ts_match_locs_array(regconfig, text, tsquery) returns int4[][2]: the same result using the selected configuration.
  • tsvector_lexemes(tsvector) returns text[]: lexemes stored in the vector, without positional metadata or weights.

Compatibility Boundary

Match locations are produced through PostgreSQL’s parser and headline internals, so validate offsets with the exact configuration, encoding, dictionary, and server version used by the application. The repository is archived and the C source depends on internal full-text-search headers. Verify compilation and regression behavior for the target PostgreSQL release; no preload is required.

Table reader