Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdXnl-0003Rn-5T for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Jul 2018 09:22:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdXnj-00042g-G3 for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Jul 2018 09:22:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdXnj-00042Y-6f for pgsql-bugs@lists.postgresql.org; Thu, 12 Jul 2018 09:22:15 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdXng-0004S5-Az for pgsql-bugs@lists.postgresql.org; Thu, 12 Jul 2018 09:22:13 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 8F29E21C27F0; Thu, 12 Jul 2018 12:22:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from zakirov.localdomain (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id F231C21C2831; Thu, 12 Jul 2018 12:22:07 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1531387328; bh=GJPx6Oif7Gvf/Dz+EAc3nFv3g6R4fJZnbDOeGd8J6Ik=; h=Date:From:To:Subject:References:In-Reply-To; b=gwcdQg0MxO3gbgD8YGvySIe2A2H35YuX6bGfEZVhQCt5HsJ5vpPYkKI5d8GETfzGU XRUH/dViGuDiTGE/cWnyP0WenzTAIRtIAk+WUzIz7vhJp6Fu4H/j2eIiprP+h8Rqyq R7f8WXdsI9SBv4S9kHVKpQjk7LxIiYCP3r3JH3pE= Date: Thu, 12 Jul 2018 12:22:06 +0300 From: Arthur Zakirov To: grinnz@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15277: ts_headline strips things that look like HTML tags and it cannot be disabled Message-ID: <20180712092205.GA16177@zakirov.localdomain> References: <153138238063.1407.1856522552479517216@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <153138238063.1407.1856522552479517216@wrigleys.postgresql.org> User-Agent: Mutt/1.10.0 (2018-05-17) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, On Thu, Jul 12, 2018 at 07:59:40AM +0000, PG Bug reporting form wrote: > I have text that is not HTML and contains things that look like HTML tags. > The headlines are HTML escaped when output. It is very odd to have this text > missing from the resulting headlines and no way to control the behavior. and are recognized as "tag" token. By default they are ignored. You need to modify existing configuration or create new one: =# CREATE TEXT SEARCH CONFIGURATION english_tag (COPY = english); =# alter text search configuration english_tag add mapping for tag with simple; Then tags aren't skipped: =# select * from ts_debug('english_tag', 'query test'); alias | description | token | dictionaries | dictionary | lexemes -----------+-----------------+-------+----------------+--------------+--------- asciiword | Word, all ASCII | query | {english_stem} | english_stem | {queri} blank | Space symbols | | {} | (null) | (null) tag | XML tag | | {simple} | simple | {} asciiword | Word, all ASCII | test | {english_stem} | english_stem | {test} tag | XML tag | | {simple} | simple | {} But even in this case ts_headline will skip tags. Because it is hardcoded [1]. I think it isn't good to change the behaviour for existing versions of PostgreSQL. But there is a workaround of course if it is appropriate for someone. It is possible to create your own text search parser extension. Example [2]. And change #define HLIDREPLACE(x) ( (x)==TAG_T ) to #define HLIDREPLACE(x) ( false ) 1 - https://github.com/postgres/postgres/blob/master/src/backend/tsearch/wparser_def.c#L1923 2 - https://github.com/postgrespro/pg_tsparser -- Arthur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company