From: Rajesh Kumar Mallah <mallah@trade-india.com>
To: Terence Kearns <terencek@isd.canberra.edu.au>
To: Oleg Bartunov <oleg@sai.msu.su>
Cc: jtx <jtx@hatesville.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: relevance
Date: Thu, 17 Jul 2003 12:45:44 +0530
Message-ID: <200307171245.44274.mallah@trade-india.com> (raw)
In-Reply-To: <3F160F2C.6050902@cts.canberra.edu.au>
References: <001001c34bfd$acad8d50$c733a8c0@slappy>
<Pine.GSO.4.56.0307170637000.12656@ra.sai.msu.su>
<3F160F2C.6050902@cts.canberra.edu.au>
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 :)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mallah@trade-india.com, terencek@isd.canberra.edu.au, oleg@sai.msu.su, jtx@hatesville.com
Subject: Re: relevance
In-Reply-To: <200307171245.44274.mallah@trade-india.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox