Re: new function for tsquery creartion
Dmitry Ivanov <d.ivanov@postgrespro.ru>
From: Dmitry Ivanov <d.ivanov@postgrespro.ru>
To: Aleksandr Parfenov <a.parfenov@postgrespro.ru>
Cc: Aleksander Alekseev <a.alekseev@postgrespro.ru>, Thomas Munro
<thomas.munro@enterprisedb.com>, David Steele <david@pgmasters.net>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-04-04T14:33:47Z
Lists: pgsql-hackers
Attachments
- websearch_to_tsquery_v8.patch (text/x-diff) patch v8
> I'm not sure about the different result for these queries:
> SELECT websearch_to_tsquery('simple', 'cat or ');
> websearch_to_tsquery
> ----------------------
> 'cat'
> (1 row)
> SELECT websearch_to_tsquery('simple', 'cat or');
> websearch_to_tsquery
> ----------------------
> 'cat' & 'or'
> (1 row)
I guess both queries should produce just 'cat'. I've changed the
definition of parse_or_operator().
> I found an odd behavior of the query creation function in case:
> SELECT websearch_to_tsquery('english', '"pg_class pg"');
> websearch_to_tsquery
> -----------------------------
> ( 'pg' & 'class' ) <-> 'pg'
> (1 row)
>
> This query means that lexemes 'pg' and 'class' should be at the same
> distance from the last 'pg'. In other words, they should have the same
> position. But default parser will interpret pg_class as two separate
> words during text parsing/vector creation.
>
> The bug wasn't introduced in the patch and can be found in current
> master. During the discussion of the patch with Dmitry, he noticed that
> to_tsquery() function shares same odd behavior:
> select to_tsquery('english', ' pg_class <-> pg');
> to_tsquery
> -----------------------------
> ( 'pg' & 'class' ) <-> 'pg'
> (1 row)
I've been thinking about this for a while, and it seems that this should
be fixed somewhere near parsetext(). Perhaps 'pg' and 'class' should
share the same position. After all, somebody could implement a parser
which would split some words using an arbitrary set of rules, for
instance "split all words containing digits". I propose merging this
patch provided that there are no objections.
--
Dmitry Ivanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Commits
-
Add websearch_to_tsquery
- 1664ae1978bf 11.0 landed
-
Add psql variables to track success/failure of SQL queries.
- 69835bc89888 11.0 cited
-
Wording improvements
- f5f1355dc4dc 8.3.0 cited