Re: Re: Matching and Scoring with multiple fields

From: Oliver Mueschke <o(at)mueschke(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Cc: tim(at)lincolnshirenow(dot)com
Subject: Re: Re: Matching and Scoring with multiple fields
Date: 2000-07-10 20:14:54
Message-ID: 20000710221454.A16918@ompc3.dom100.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm not sure, but it seems you could calculate a column like:
SELECT a,b,c,...,
abs(<feel_a>-a)+abs(<feel_b>-b)+abs(<feel_c>-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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ed Loehr 2000-07-10 21:31:08 Re: Re: Matching and Scoring with multiple fields
Previous Message Ed Loehr 2000-07-10 19:07:31 Re: Timestamp problem