[BUGS] pg_trgm word_similarity inconsistencies or bug - Mailing list pgsql-bugs

From Cristiano Coelho
Subject [BUGS] pg_trgm word_similarity inconsistencies or bug
Date
Msg-id CY4PR17MB13207ED8310F847CF117EED0D85A0@CY4PR17MB1320.namprd17.prod.outlook.com
Whole thread Raw
Responses Re: [BUGS] pg_trgm word_similarity inconsistencies or bug  (Arthur Zakirov <a.zakirov@postgrespro.ru>)
List pgsql-bugs

Hello all, this is related to postgres 9.6 (9.6.4) and a good description can be found here https://stackoverflow.com/questions/46966360/postgres-word-similarity-not-comparing-words

 

But in summary, word_similarity doesn’t seem to do exactly what the docs say, since it will match trigrams from multiple words rather tan doing a word by word comparison.

 

Below is a table with output and expected output, thanks to kiln from stackoverflow to provide it.

 

 

with data(t) as (
values
('message'),
('message s'),
('message sag'),
('message sag sag'),
('message sag sage')
)
 
select t, word_similarity('sage', t), my_word_similarity('sage', t)
from data;
 
        t         | word_similarity | my_word_similarity
------------------+-----------------+--------------------
 message          |             0.6 |                0.3
 message s        |             0.8 |                0.3
 message sag      |               1 |                0.5
 message sag sag  |               1 |                0.5
 message sag sage |               1 |                  1

 

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] ORDER BY $1 behaves inconsistently
Next
From: Jordan Lewis
Date:
Subject: Re: [BUGS] ORDER BY $1 behaves inconsistently