BUG #18479: websearch_to_tsquery inconsistent behavior for german when using parentheses

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: esemmano(at)gmail(dot)com
Subject: BUG #18479: websearch_to_tsquery inconsistent behavior for german when using parentheses
Date: 2024-05-24 07:02:28
Message-ID: 18479-d9b46e2fc242c33e@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18479
Logged by: Manos Emmanouilidis
Email address: esemmano(at)gmail(dot)com
PostgreSQL version: 15.4
Operating system: macOS Sonoma 14.4.1 x86
Description:

Although the docs
https://www.postgresql.org/docs/current/textsearch-controls.html say nothing
about websearch_to_tsquery supporting parentheses in queries, I noticed some
inconsistent behaviour when using multiple 'or' keywords with parentheses in
postgres 15.4

In the following tests 1-3 the behaviour matches what I expect, but in the
4th test the 'or' keyword is used verbatim when parentheses are present in
the middle of the query.

select websearch_to_tsquery('german', 'foo or baz bar');
websearch_to_tsquery
-----------------------
'foo' | 'baz' & 'bar'

select websearch_to_tsquery('german', 'foo or baz bar or ding dong');
websearch_to_tsquery
-----------------------------------------
'foo' | 'baz' & 'bar' | 'ding' & 'dong'

select websearch_to_tsquery('german', 'foo or baz bar or (ding dong)');
websearch_to_tsquery
-----------------------------------------
'foo' | 'baz' & 'bar' | 'ding' & 'dong'

select websearch_to_tsquery('german', 'foo or (baz bar) or (ding dong)');
websearch_to_tsquery
------------------------------------------------
'foo' | 'baz' & 'bar' & 'or' & 'ding' & 'dong'

I do not mean to say that this is necessarily a bug that needs fixing, but
maybe either the docs should call out that using parens leads to undefined
behaviour, or the function's logic could be updated to be consistent in the
presence of parens - either ignore them completely or always consider them,
but not both depending on the input

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marcin Barczyński 2024-05-24 08:26:50 Re: BUG #18334: Segfault when running a query with parallel workers
Previous Message PG Bug reporting form 2024-05-24 05:01:32 BUG #18478: uuid-ossp extension is not installed with PostgreSQL 17 Beta 1