how to group by similarity ?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: how to group by similarity ?
Date: 2012-04-24 18:07:34
Message-ID: 4F96EBE6.1060603@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm trying to get an idea about pg_trgrm.
I created a GIST index on a text column in a table.
Now I can filter the table with similarity().

How would I group the table so that it shows groups that have similarity
() > x ?

Lets say the table looks like this:

id, txt
1, aa1
2, bb1
3, cc1
4, bb2
5, bb3
6, aa2
...

How would a select look like that shows:

id, txt, group_id
1, aa1, 1,
6, aa2, 1,
2, bb1, 2,
4, bb2, 2,
5, bb3, 2,
3, cc1, 3

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Emi Lu 2012-04-24 18:10:24 Re: [SQL] Simple way to get missing number
Previous Message Andreas Kretschmer 2012-04-24 16:06:21 Re: Simple way to get missing number