I have a query that uses phrase search to match whole phrases.
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')
);
Which results in:
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>.
But I would have expected this:
This is my test text. My test <b>text</b> <b>has</b> <b>many</b> <b>words</b>. Well, not THAT many words.
Or ideally even this:
This is my test text. My test <b>text has many words</b>. Well, not THAT many words.
Sidenote:
phraseto_tsquery('simple', 'text has many words')
is equivalent to
to_tsquery('simple', 'text <-> has <-> many <-> words')
I'm not sure if I'm doing something wrong, or if ts_headline simply does not support this kind of highlighting.