Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators

From: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>
To: jordanthelewis(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
Date: 2022-07-11 12:34:37
Message-ID: CALT9ZEHmajgi1mc9-2VRPLzmvs_n26mSmgXxD4yGY2p9oEf7_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>
> Consider the following query:
>
> jordan=> select '((a <2> c) & (b <-> c)) <-> d'::tsquery @@ 'a:1 b:2 c:3
> d:4';
> ?column?
> ----------
> f
> (1 row)
>
> I think this should return "true", because both of the expressions on the
> left-hand-side of the outer <-> operator of the tsquery do in fact precede
> the "d" term in the tsvector.
>
> Here is output that shows this:
>
> jordan=> select '((a <2> c)) <-> d'::tsquery @@ 'a:1 b:2 c:3 d:4';
> ?column?
> ----------
> t
> (1 row)
>
> jordan=> select '((b <-> c)) <-> d'::tsquery @@ 'a:1 b:2 c:3 d:4';
> ?column?
> ----------
> t
> (1 row)
>
> I think things go wrong in the query executor because the two LHS clauses
> have different widths.
>
> Do you agree that this is incorrect output?
>
I guess this result is derived from the agreement that logical operation
inside the phrase operator is treated as
"both operands a and b are in the _same_ position just before c".

select '(a & b) <-> c'::tsquery @@ 'a:1 b:1 c:2';
?column?
----------
t
(1 row)

Though it's not clear what it means if there is another phrase operator
inside logical. Result positions of (a <2> c) and (b <-> c) are different,
I guess. It's not clear to me how should this behave in the case of a chain
of nested phrase-logical-phrase operations.

--
Best regards,
Pavel Borisov

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jordan Lewis 2022-07-11 13:18:34 Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
Previous Message David G. Johnston 2022-07-11 12:31:35 Re: BUG #17543: CSVLOG malformed from disk space error