Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qwqCu-00EbZd-3R for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Oct 2023 20:46:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qwqCq-005Vzx-JJ for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Oct 2023 20:46:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qwqCq-005VyJ-Ad for pgsql-bugs@lists.postgresql.org; Sat, 28 Oct 2023 20:46:52 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qwqCh-002mRU-0c for pgsql-bugs@lists.postgresql.org; Sat, 28 Oct 2023 20:46:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 39SKkeiP1995602; Sat, 28 Oct 2023 16:46:40 -0400 From: Tom Lane To: Bruce Momjian cc: Alex Malek , pgsql-bugs@lists.postgresql.org, ngigi@at.co.ke Subject: Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly In-reply-to: References: <152461454026.19805.6310947081647212894@wrigleys.postgresql.org> Comments: In-reply-to Bruce Momjian message dated "Sat, 28 Oct 2023 15:42:16 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1995600.1698526000.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Oct 2023 16:46:40 -0400 Message-ID: <1995601.1698526000@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bruce Momjian writes: > Is this documented somewhere? The docs [1] only say that ts_headline "returns an excerpt from the document in which terms from the query are highlighted". This behavior does not violate that admittedly-weak contract. IIRC, ts_headline does attempt to find a text fragment or fragments that fully satisfy the query (e.g., include an exact phrase match) but it will then highlight all the matching words in the fragment, not only the location of the phrase match. I do not agree with the OP's opinion that that's wrong. The highlight-em-all approach has its own value, and in any case it may not be possible to find a full match that satisfies the function's other constraints such as MaxWords. Refusing to highlight anything in that event would be unhelpful. regards, tom lane [1] https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTS= EARCH-HEADLINE