Received: from host1.internetdevelopment.co.uk (IDENT:root@host1.internetdevelopment.co.uk [195.182.175.8]) by hub.org (8.10.1/8.10.1) with ESMTP id e6D0ufW13401 for ; Wed, 12 Jul 2000 20:56:50 -0400 (EDT) Received: from tim (cheese27.otago.co.uk [195.182.175.127]) by host1.internetdevelopment.co.uk (8.9.3/8.8.7) with SMTP id BAA17043; Thu, 13 Jul 2000 01:14:02 +0100 Reply-To: From: "Tim Johnson" To: "Oliver Mueschke" , Cc: "Stephan Szabo" , Subject: RE: Re: Matching and Scoring with multiple fields Date: Thu, 13 Jul 2000 01:13:21 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 In-Reply-To: <20000710221454.A16918@ompc3.dom100.de> Importance: Normal X-Archive-Number: 200007/139 Thanks to all of you that replied. I think Oliver's idea (which is pretty close to Stephan's) will probably do the trick I think. I will maybe look in the future to add the ability to allow users to weight fields with more priority. So customers could number the top five most important fields and then pick how they feel. I still worry about the results being skewed by extreme data in certain fields but I guess there's no way around that. Thanks again. Tim Johnson, -- http://www.theinkfactory.co.uk -----Original Message----- From: Oliver Mueschke [mailto:o@mueschke.de] Sent: 10 July 2000 21:15 To: pgsql-sql@postgresql.org Cc: tim@lincolnshirenow.com Subject: Re: [SQL] Re: Matching and Scoring with multiple fields I'm not sure, but it seems you could calculate a column like: SELECT a,b,c,..., abs(-a)+abs(-b)+abs(-c)+... AS weight FROM t ORDER BY weight This way the closest matches would come first. On Mon, Jul 10, 2000 at 07:56:08PM +0100, Tim Johnson wrote: > I have a problem. Ok I'll rephrase that, a challenge. > > I have a table like this: > > a,b,c,d,e,f,g,h > --------------- > 2,5,3,4,4,5,2,2 > 1,1,1,1,1,1,1,1 > 5,5,5,5,5,5,5,5 > 3,3,2,4,5,1,1,3 > 1,1,5,5,5,5,1,4 > 1,5,5,5,4,4,2,1 > 5,5,5,5,1,1,1,1 > 1,1,1,1,5,5,5,5 > (rows 8) > > a to h are of type int. > > > I want to take input values which relate to this table say: > how do you feel about a: > how do you feel about b: > how do you feel about c: > ... > > and the answers will be 1 to 5. > > Now I want to take those answers for my incoming a to h and scan down the > table pulling out the closest matches from best to worst. There will be > about 2000 rows in the final table and I will LIMIT the rows in blocks of 10 > or so.