Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 096AA475B99 for ; Mon, 4 Nov 2002 18:26:08 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 6CFF9475B8F for ; Mon, 4 Nov 2002 18:26:07 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1812070; Mon, 04 Nov 2002 15:28:44 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Ross J. Reedstrom" , pgsql-sql@postgresql.org Subject: Re: counting text matches - any recipes? Date: Mon, 4 Nov 2002 15:26:12 -0800 X-Mailer: KMail [version 1.4] References: <20021104225320.GA6001@wallace.ece.rice.edu> In-Reply-To: <20021104225320.GA6001@wallace.ece.rice.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211041526.12931.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/49 X-Sequence-Number: 10191 Ross, > For the basic interface, we have the user types some words into a textbox, > then just search 'everything'. I'm weighting the results, so that hits > on the title count more than on keywords, which count more than on the > abstract, which count more than in the body. Before you re-invent the wheel, have you checked out OpenFTS? www.openfts.= org=20 (I think). >=20 > This is working reasonably well, but I'm stuck on one counting problem: > what's the natural way to count multiple matches in SQL? Within a single text field? There isn't. 2 choices: 1) Use a Full Text Searching engine, such as the simple one in /contrib or = a=20 more full-featured one like OpenFTS. Both will allow you to do counts on= =20 "hits" for a keyword. 2) Write a function in PL/perl which will count the number of keyword match= es=20 in a text string. Potentially slower than #1, but easier to implement. --=20 -Josh Berkus Aglio Database Solutions San Francisco