Received: from em.gfxsp.com (ABCS.DLCI.26 [206.230.114.60] (may be forged)) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0FHiQ089937 for ; Mon, 15 Jan 2001 12:44:26 -0500 (EST) (envelope-from cbm@gfxsp.com) Received: from cbm1 ([192.168.1.11]) by em.gfxsp.com (8.9.3/8.8.7) with SMTP id MAA20223 for ; Mon, 15 Jan 2001 12:46:14 -0500 Message-ID: <002901c07f1a$e4887800$0b01a8c0@graphicfx.net> From: "Chad McKay" To: Subject: Sort by relevance Date: Mon, 15 Jan 2001 12:44:59 -0500 Organization: Graphic FX MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0026_01C07EF0.F8A6B6A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200101/147 X-Sequence-Number: 808 This is a multi-part message in MIME format. ------=_NextPart_000_0026_01C07EF0.F8A6B6A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I am trying to use a perl script to break an input string into keywords and pull out all the records that match any of them: my (@chips)=3D split(' ', $f_name); foreach my $chip (@chips) { next if ($stoppers=3D~/ $chip / || length($chip) < 3); if ($query) {$query .=3D " OR name ~* '.*$chip.*' ";} else {$query =3D "SELECT * FROM info WHERE name ~* '.*$chip.*' ";} } this works fine for pulling the records but I would like to sort them by how many of the "chips" matched. On a set like: name ------------- Bill Smith Ted Smith Ted Brown an input of : Ted Smith would give me a query string of: SELECT * FROM info WHERE name ~* '.*Ted.*' or name~*'.*Smith.*' which returns all records - which is what I want - but I would like to have Ted Smith in the first row followed by the other records grouped by name and sorted on another column (city or state in the real table) Thanks for your help, Chad McKay ------=_NextPart_000_0026_01C07EF0.F8A6B6A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,

I am trying to use a perl script to break an input strin= g=20 into keywords and
pull out all the records that match any of them:
my=20 (@chips)=3D split(' ', $f_name);
foreach my $chip (@chips)=20 {
    next if ($stoppers=3D~/ $chip / || length($chip) &l= t;=20 3);
    if ($query) {$query .=3D " OR name ~* '.*$chip.*'= =20 ";}
    else {$query =3D "SELECT * FROM info WHERE name ~= *=20 '.*$chip.*' ";}
}

this works fine for pulling the records but I w= ould=20 like to sort them by how
many of the "chips" matched.

On a set=20 like:

name
-------------
Bill Smith
Ted Smith
Ted=20 Brown

an input of : Ted Smith
would give me a query string=20 of:
        SELECT * FROM info WHERE = name=20 ~* '.*Ted.*' or name~*'.*Smith.*'

which returns all records - which = is=20 what I want - but I would like to have
Ted Smith in the first row follow= ed by=20 the other records grouped by name and
sorted on another column (cit= y or=20 state in the real table)

Thanks for your help,
Chad=20 McKay

------=_NextPart_000_0026_01C07EF0.F8A6B6A0--