X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 2A6B4CC8AA for ; Thu, 17 Jul 2003 08:39:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 49464-05 for ; Thu, 17 Jul 2003 08:39:57 +0000 (GMT) Received: from isd.canberra.edu.au (isd.canberra.edu.au [137.92.10.5]) by svr1.postgresql.org (Postfix) with ESMTP id 3BF4CCC863 for ; Thu, 17 Jul 2003 05:39:29 -0300 (ADT) Received: from cts.canberra.edu.au (fooey.canberra.edu.au [137.92.10.57]) by isd.canberra.edu.au (8.12.9/8.12.6) with ESMTP id h6H8duCF019062; Thu, 17 Jul 2003 18:39:57 +1000 (EST) Message-ID: <3F1660B9.3060801@cts.canberra.edu.au> Date: Thu, 17 Jul 2003 18:39:21 +1000 From: Terence Kearns User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en-au, en-gb, en, en-us MIME-Version: 1.0 To: pgsql-sql@postgresql.org Cc: Rajesh Kumar Mallah Subject: Re: relevance References: <001001c34bfd$acad8d50$c733a8c0@slappy> <3F160F2C.6050902@cts.canberra.edu.au> <200307171245.44274.mallah@trade-india.com> In-Reply-To: <200307171245.44274.mallah@trade-india.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/212 X-Sequence-Number: 14326 Rajesh Kumar Mallah wrote: > > > 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. > Tsearch2 looks like it would be very useful but it's a lot of work to implement IMHO. At least it will probably (assumption) be a lot more efficient for massive amounts of data. Remember the original question was regarding how to list results in order of how many hits were returned for each matched record. -- Terence Kearns ~ ph: +61 2 6201 5516 IT Database/Applications Developer Enterprise Information Systems Client Services Division University of Canberra www.canberra.edu.au