pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
3+ messages / 3 participants
[nested] [flat]
* BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
@ 2022-07-09 01:35 PG Bug reporting form <noreply@postgresql.org>
2022-07-11 12:34 ` Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators Pavel Borisov <pashkin.elfe@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2022-07-09 01:35 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: jordanthelewis@gmail.com
The following bug has been logged on the website:
Bug reference: 17542
Logged by: Jordan Lewis
Email address: jordanthelewis@gmail.com
PostgreSQL version: 14.3
Operating system: Linux
Description:
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?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
2022-07-09 01:35 BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators PG Bug reporting form <noreply@postgresql.org>
@ 2022-07-11 12:34 ` Pavel Borisov <pashkin.elfe@gmail.com>
2022-07-11 13:18 ` Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators Jordan Lewis <jordanthelewis@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Borisov @ 2022-07-11 12:34 UTC (permalink / raw)
To: jordanthelewis@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
>
> 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators
2022-07-09 01:35 BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators PG Bug reporting form <noreply@postgresql.org>
2022-07-11 12:34 ` Re: BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators Pavel Borisov <pashkin.elfe@gmail.com>
@ 2022-07-11 13:18 ` Jordan Lewis <jordanthelewis@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Jordan Lewis @ 2022-07-11 13:18 UTC (permalink / raw)
To: Pavel Borisov <pashkin.elfe@gmail.com>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
On Mon, Jul 11, 2022, 08:35 Pavel Borisov <pashkin.elfe@gmail.com> wrote:
> 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.
>
I would expect that the "position" of a match should depend on whether it's
the LHS or RHS of the phrase operator. If it's the LHS, I'd expect the
"position" to be the "end" of the match. If it's the RHS, I'd expect the
"position" to be the "beginning" of the match.
Maybe that's the wrong intuition and it's always the beginning of the match?
Jordan
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-07-11 13:18 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 01:35 BUG #17542: tsquery returns incorrect results with nested, conjuncted followed-by operators PG Bug reporting form <noreply@postgresql.org>
2022-07-11 12:34 ` Pavel Borisov <pashkin.elfe@gmail.com>
2022-07-11 13:18 ` Jordan Lewis <jordanthelewis@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox