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

From Pavel Borisov
Subject Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
Date
Msg-id CALT9ZEHmajgi1mc9-2VRPLzmvs_n26mSmgXxD4yGY2p9oEf7_w@mail.gmail.com
Whole thread Raw
In response to BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators  (Jordan Lewis <jordanthelewis@gmail.com>)
List 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

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17543: CSVLOG malformed from disk space error
Next
From: Jordan Lewis
Date:
Subject: Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators