2.6. Headline

CREATE FUNCTION headline([ id int4, | ts_name text, ] document text, query TSQUERY, [ options text ]) RETURNS text

Every form of the the headline() function accepts a document along with a query, and returns one or more ellipse-separated excerpts from the document in which terms from the query are highlighted. The configuration with which to parse the document can be specified by either its id or ts_name; if none is specified that the current configuration is used instead.

An options string if provided should be a comma-separated list of one or more 'option=value' pairs. The available options are:

Any unspecified options receive these defaults:

StartSel=<b>, StopSel=</b>, MaxWords=35, MinWords=15, ShortWord=3, HighlightAll=FALSE

Notice, that cascade dropping of headline function cause dropping of parser, used in fulltext configuration tsname.

select headline('a b c', 'c'::tsquery);
   headline
--------------
 a b <b>c</b>
=# select headline('a b c', 'c'::tsquery, 'StartSel=<,StopSel=>');
 headline
----------
 a b  <c>