Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Alex Malek <magicagent@gmail.com>, pgsql-bugs@lists.postgresql.org,
ngigi@at.co.ke
Date: 2023-10-30T16:23:11Z
Lists: pgsql-bugs
Bruce Momjian <bruce@momjian.us> writes: > Sold! :-) Attached. LGTM. BTW, just for the OP's context: ts_headline was designed before we had phrase search operators. With only AND/OR/NOT, there aren't any location restrictions on individual words. (I recall that we occasionally got complaints about how it shouldn't highlight words that are supposed to NOT be there, but that was an uncommon situation because normally you wouldn't be selecting such a document to highlight.) So both the function's basic algorithm and its control parameters were designed without thought for what to do if the query restricted match locations. Maybe there's a case for rethinking what it should do more than we already have; but it's not clear that you can do much better without throwing out the current set of control parameters as well as the algorithm. See [1] for some context and discussion. regards, tom lane [1] https://www.postgresql.org/message-id/flat/840.1669405935%40sss.pgh.pa.us