Re: Range phrase operator in tsquery - Mailing list pgsql-hackers

From Dmitry Dolgov
Subject Re: Range phrase operator in tsquery
Date
Msg-id CA+q6zcXyRY6kKpuXAJgvznyA0Jj3tOe=XkQ1n7e3XaE44ZW1Rw@mail.gmail.com
Whole thread Raw
In response to Re: Range phrase operator in tsquery  (Aleksandr Parfenov <a.parfenov@postgrespro.ru>)
Responses Re: Range phrase operator in tsquery
List pgsql-hackers
> On Fri, 27 Apr 2018 at 13:03, Aleksandr Parfenov <a.parfenov@postgrespro.ru> wrote:
>
> Nowadays, phrase operator in Postgres FTS supports only exact match of
> the distance between two words. It is sufficient for a search of
> simple/exact phrases, but in some cases exact distance is unknown and we
> want to words be close enough. E.g. it may help to search phrases with
> additional words in the middle of the phrase

Hi,

Thank you for the patch, it looks like a nice feature. Few questions:

+ if (!distance_from_set)
+ {
+ distance_from = distance_to < 0 ? MINENTRYPOS : 0;
+ }
+ if (!distance_to_set)
+ {
+ distance_to = distance_from < 0 ? 0 : MAXENTRYPOS;
+ }

Why use 0 here instead of MAXENTRYPOS/MINENTRYPOS ? It looks a bit strange:

SELECT 'a <,-1000> b'::tsquery;
        tsquery
------------------------
 'a' <-16384,-1000> 'b'
(1 row)

SELECT 'a <,1000> b'::tsquery;
     tsquery
------------------
 'a' <0,1000> 'b'
(1 row)

Also I wonder why after introducing MINENTRYPOS the LIMITPOS wasn't changed?

#define LIMITPOS(x) ( ( (x) >= MAXENTRYPOS ) ? (MAXENTRYPOS-1) : (x) )


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Some incorrect comments and out-dated README from run-timepruning
Next
From: Peter Eisentraut
Date:
Subject: Re: A small tweak to some comments for PartitionKeyData