如何让ts_headline尊重phraseto_tsquery

时间:2018-03-26 16:09:10

标签: postgresql full-text-search postgresql-9.6

我有一个使用短语搜索来匹配整个短语的查询。

SELECT ts_headline(
  'simple',
  'This is my test text. My test text has many words. Well, not THAT many words.',
  phraseto_tsquery('simple', 'text has many words')
);

结果是:

This is my test <b>text</b>. My test <b>text</b> <b>has</b> <b>many</b> <b>words</b>. Well, not THAT <b>many</b> <b>words</b>.

但我原本预料到了这一点:

This is my test text. My test <b>text</b> <b>has</b> <b>many</b> <b>words</b>. Well, not THAT many words.

理想情况下甚至是这样:

This is my test text. My test <b>text has many words</b>. Well, not THAT many words.

旁注:

phraseto_tsquery('simple', 'text has many words')

相当于

to_tsquery('simple', 'text <-> has <-> many <-> words')

我不确定我是否做错了,或者ts_headline是否支持这种突出显示。

1 个答案:

答案 0 :(得分:3)

phraseto_tsquery('simple', 'text has many words')生成正确的查询,但是问题似乎出在ts_headline函数中。好像已经报告了错误#155172