From: 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:51:24 +1000
Message-ID: <3F160F2C.6050902@cts.canberra.edu.au> (raw)
In-Reply-To: <Pine.GSO.4.56.0307170637000.12656@ra.sai.msu.su>
References: <001001c34bfd$acad8d50$c733a8c0@slappy>
<Pine.GSO.4.56.0307170637000.12656@ra.sai.msu.su>
>>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).
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 :)
--
Terence Kearns ~ ph: +61 2 6201 5516
IT Database/Applications Developer
Enterprise Information Systems
Client Services Division
University of Canberra
www.canberra.edu.au
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: terencek@isd.canberra.edu.au, oleg@sai.msu.su, jtx@hatesville.com
Subject: Re: relevance
In-Reply-To: <3F160F2C.6050902@cts.canberra.edu.au>
* 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