From: | Rajesh Kumar Mallah <mallah(at)trade-india(dot)com> |
---|---|
To: | Terence Kearns <terencek(at)isd(dot)canberra(dot)edu(dot)au>, Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> |
Cc: | jtx <jtx(at)hatesville(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: relevance |
Date: | 2003-07-17 07:15:44 |
Message-ID: | 200307171245.44274.mallah@trade-india.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thursday 17 Jul 2003 8:21 am, Terence Kearns wrote:
> >>select id from tablename where message like '%sql%';
> >>
> >>If there any way to determine exactly how many times 'sql' is matched in
> >>that search in each particular row, and then sort by the most matches,
> >>or am I going to have to write a script to do the sorting for me?
>
> You could probably write a function in postgres (say, "matchcount()")
> which returns the match count (possibly using perl and a regex).
Why reinvent the wheel when tsearch already does the job perfectly
and is PostgreSQL compaitable.
Regds
Mallah.
>
> SELECT matchcount(message,'sql') AS matchcount, id
> FROM tablename
> WHERE message LIKE '%sql%'
> ORDER BY matchcount(message,'sql') DESC
>
> The ORDER BY will probably fail, but you can try :)
From | Date | Subject | |
---|---|---|---|
Next Message | Terence Kearns | 2003-07-17 08:39:21 | Re: relevance |
Previous Message | BenLaKnet | 2003-07-17 06:44:15 | Re: Recursive request ... |