PostgreSQL, trigrams and similarity : <p>Just testing PostgreSQL 9.6.2 on my Mac and playing with Ngrams.
Assuming there is a GIN trigram index on winery field.</p>

<p>The limit for similarity (I know this is deprecated):</p>

<pre><code>SELECT set_limit(0.5);
</code></pre>

<p>I'm building a trigram search on 2,3M row table.</p>

<p>My select code:</p>

<pre><code>SELECT winery, similarity(winery, 'chateau chevla blanc') AS similarity 
FROM usr_wines 
WHERE status=1 AND winery % 'chateau chevla blanc'  
ORDER BY similarity DESC;
</code></pre>

<p>My results (329 ms on my mac):</p>

<pre><code>Chateau ChevL Blanc 0,85
Chateau Blanc   0,736842
Chateau Blanc   0,736842
Chateau Blanc   0,736842
Chateau Blanc   0,736842
Chateau Blanc,  0,736842
Chateau Blanc   0,736842
Chateau Cheval Blanc    0,727273
Chateau Cheval Blanc    0,727273
Chateau Cheval Blanc    0,727273
Chateau Cheval Blanc (7)    0,666667
Chateau Cheval Blanc Cbo    0,64
Chateau Du Cheval Blanc 0,64
Chateau Du Cheval Blanc 0,64
</code></pre>

<p>Well, I don't understand how can "Chateau blanc" have a similarity > to "Chateau Cheval Blanc" in this case ? I understand that the 2 words are the exact same "chateau" and "blanc", but there is no other word "cheval".</p>

<p>Also why "Chateau ChevL Blanc" is first ? A letter "a" is missing !</p>

<p>Well, my goal is to match all possible duplicates when I give a winery name, even if it's mispelled. What did I miss ?</p>
