是否有ts(文本搜索)函数将返回找到的字符串而不是布尔值? ts_headline输出我正在寻找如下所述的唯一字符串:

我正在使用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>.    

我正在寻找如下所述的唯一字符串:

查询,相似度

uhkul 回答:是否有ts(文本搜索)函数将返回找到的字符串而不是布尔值? ts_headline输出我正在寻找如下所述的唯一字符串:

如果您确定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'
     );
本文链接:https://www.f2er.com/3168046.html

大家都在问