Re: tgrm index for word_similarity

From: Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: "Igal (at) Lucee(dot)org" <igal(at)lucee(dot)org>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: tgrm index for word_similarity
Date: 2017-10-21 12:01:05
Message-ID: 20171021120104.GA1563@arthur.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 19, 2017 at 04:54:19PM -0700, Igal @ Lucee.org wrote:
>
> My query at the moment is:
>
>     SELECT name, popularity
>     FROM   temp.items3_v
>           ,(values ('some phrase'::text)) consts(input)
>     WHERE  true
>         and word_similarity(input, name) > 0.01  -- be lenient as some names
> are 75 characters long and we want to match even on a few characters of
> input
>     ORDER BY 2, input <<-> name
>

PostgreSQL doesn't use index scan with functions within WHERE clause. So
you always need to use operators instead. You can try <% operator and
pg_trgm.word_similarity_threshold variable:

=# SET pg_trgm.word_similarity_threshold TO 0.1;
=# SELECT name, popularity
FROM temp.items3_v
,(values ('some phrase'::text)) consts(input)
WHERE input <% name
ORDER BY 2, input <<-> name;

--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message doganmeh 2017-10-21 12:24:42 Re: Restoring tables with circular references dumped to separate files
Previous Message Uwe 2017-10-21 06:09:30 Re: Restoring tables with circular references dumped to separate files