是否有 ts(文本搜索)函数 return 找到字符串而不是布尔值?

Is there a ts (text search) function would return found string instead of boolean?

我正在使用 PostgreSQL 通过 tsvectortsquery 找出文章中匹配的字符串。

我阅读了 PostgreSQL 手册 12.3 控制文本搜索,但没有任何方法可以帮助我获得我想要的准确输出。

查询:

SELECT ts_headline('english',
  'The most common type of search
is to find all documents containing given query terms
and return them in order of their similarity to the
query.',
  to_tsquery('query & similarity'),
  'StartSel = <, StopSel = >');

ts_headline输出

The most common type of search
is to find all documents containing given <query> terms
and return them in order of their <similarity> to the
<query>.    

我正在寻找下面提到的唯一字符串:

查询,相似度

如果您为 StartSel 和 StopSel 选择了您确定在字符串中其他地方不存在的分隔符,那么使用 a regexp.

可以很容易地做到这一点
 SELECT  distinct regexp_matches[1] from
     regexp_matches(
        ts_headline('english',
  'The most common type of search
is to find all documents containing given query terms
and return them in order of their similarity to the
query.',
            to_tsquery('query & similarity'),
            'StartSel = <, StopSel = >'
         ),
         '<(.*?)>','g'
     );