Re: Precedence of new phrase search tsquery operator - Mailing list pgsql-hackers

From Oleg Bartunov
Subject Re: Precedence of new phrase search tsquery operator
Date
Msg-id CAF4Au4wSSxkdJCNruSJxgKX_PGWZ9y6RYDPiWrNF0Yi89tbOAw@mail.gmail.com
Whole thread Raw
In response to Precedence of new phrase search tsquery operator  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Jun 8, 2016 at 7:13 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> It appears that the new <-> operator has been made to have exactly the
> same grammatical precedence as the existing & (AND) operator.  Thus,
> for example, 'a & b <-> c'::tsquery means something different from
> 'b <-> c & a'::tsquery:
>
> regression=# select 'a & b <-> c'::tsquery;
>               tsquery
> -----------------------------------
>  ( 'a' <-> 'c' ) & ( 'b' <-> 'c' )
> (1 row)
>
> regression=# select 'b <-> c & a'::tsquery;
>         tsquery
> -----------------------
>  ( 'b' <-> 'c' ) & 'a'
> (1 row)
>
> I find this surprising.  My intuitive feeling is that <-> ought to
> bind tighter than & (and therefore also tighter than |).  What's
> the reasoning for making it act like this?

I don't remember, but it looks like a bug. I found another issue with that

If some dictionary returns two infinitives, like:

select * from to_tsquery('en','leavings');     to_tsquery
----------------------'leavings' | 'leave'
(1 row)


then following query looks like a bug

select to_tsquery('en', 'aa & leavings <-> tut');                           to_tsquery
-------------------------------------------------------------------( 'aa' <-> 'tut' ) & ( 'leavings' <-> 'tut' |
'leave'<-> 'tut' )
 
(1 row)

It should be definitely

select to_tsquery('en', 'aa & leavings <-> tut');                           to_tsquery
------------------------------------------------------------------- 'aa'  & ( 'leavings' <-> 'tut' | 'leave' <-> 'tut'
)
(1 row)

so, yes, <-> should be more tight than &.

>
>                         regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Precedence of new phrase search tsquery operator
Next
From: Oleg Bartunov
Date:
Subject: Re: Precedence of new phrase search tsquery operator