Previous   Next 

Function headline

Returns a substring within a string that matches a search query. Matching search words within the substring are surrounded by '<b>' and '</b>' by default.

headline([configuration OID | TEXT, ] txt TEXT, tsq TSQUERY [, options TEXT]) RETURNS TEXT

  • If specified, 'configuration' is the int oid or text name of a configuration listed in table pg_ts_cfg.
  • 'txt' is the text string to search through for a headline substring.
  • 'tsq' is a text search query to match against 'txt'.
  • 'options' defines the characters to use to surround matching words, the maximum and minimum words to use in a headline, and the minimum number of characters to in a word which starts or ends a headline. The default value for options is 'StartSel=<b>, StopSel=</b>, MaxWords=35, MinWords=15, ShortWord=3'.
select set_curcfg('default_english');
 
 set_curcfg
------------

(1 row)

SELECT file, 
    headline(body, to_tsquery('updateable & views'), 
        'StartSel=<b>, StopSel=</b>, MaxWords=11, MinWords=10, ShortWord=3') 
FROM postgresql_manual 
WHERE ts_vec @@ to_tsquery('updateable & views') 
ORDER BY rank(ts_vec, to_tsquery('updateable & views')) DESC 
LIMIT 3;
         
	 file        |                                          headline
---------------------+--------------------------------------------------------------------------------------------
sql-createview.html  |view.  You can get the effect of an updatable     view
sql-createrule.html  |updatable view by defining     ON INSERT ,  ON UPDATE , and     ON DELETE
infoschema-views.html|view)            check_option    character_data   Applies to a feature not available
(3 rows)