Re: Text search lexer's handling of hyphens and negatives - Mailing list pgsql-general

From Daniel Verite
Subject Re: Text search lexer's handling of hyphens and negatives
Date
Msg-id abf85423-ce4b-45ec-97a4-2789a400ed55@manitou-mail.org
Whole thread Raw
In response to Text search lexer's handling of hyphens and negatives  (raylu <lurayl@gmail.com>)
List pgsql-general
    raylu wrote:

> to_tsvector('simple', 'UVW-789-XYZ') is
> 'uvw':1 '-789':2 'xyz':3
> because -789 is a negative integer. If we turn the query '789-XYZ'
> into the tsquery as before, we get to_tsquery('simple', '789 <-> xyz')
> which doesn't match it.
>
> Are we missing something here? Is there either a way to
> 1. generate tsvectors without this special (negative) integer behavior or

As an ad-hoc solution, you could add a dictionary that turns a negative
integer into its positive counterpart. There's a dictionary in contrib that
can be used as a starting point:
https://www.postgresql.org/docs/current/dict-int.html

It's a matter of ~10 lines of C code to add an "abs" parameter to
that dictionary that would, when true, produce "789" as a lexem
when fed "-789" as input.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



pgsql-general by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: Is there any configuration in postgresql.conf or any otherconfiguration of postgres which will make this possible to listen onparticular interface
Next
From: Thomas Kellerer
Date:
Subject: A little confusion about JSON Path