Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id B4C539FB8AB for ; Mon, 26 Feb 2007 15:01:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 04431-09 for ; Mon, 26 Feb 2007 15:01:16 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.alteeve.com (unknown [192.139.81.120]) by postgresql.org (Postfix) with ESMTP id BB5DD9FB8EA for ; Mon, 26 Feb 2007 15:01:17 -0400 (AST) Received: from [192.168.1.99] ([192.168.1.1]) by mail.alteeve.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l1QJ0K4X004791; Mon, 26 Feb 2007 14:00:21 -0500 Message-ID: <45E32E21.9090901@alteeve.com> Date: Mon, 26 Feb 2007 13:59:45 -0500 From: Madison Kelly User-Agent: Icedove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Mark Stosberg CC: pgsql-performance@postgresql.org Subject: Re: Writting a "search engine" for a pgsql DB References: <45E30ADA.2050700@alteeve.com> <45E31300.4070701@commandprompt.com> <45E31D28.2020402@alteeve.com> <45E323AB.1040009@summersault.com> In-Reply-To: <45E323AB.1040009@summersault.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.119 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/308 X-Sequence-Number: 23362 Mark Stosberg wrote: > Madison Kelly wrote: >> I think the more direct question I was trying to get at is "How do you >> build a 'relavence' search engine? One where results are returned/sorted >> by relevance of some sort?". At this point, the best I can think of, >> would be to perform multiple queries; first matching the whole search >> term, then the search term starting a row, then ending a row, then >> anywhere in a row and "scoring" the results based on which query they >> came out on. This seems terribly cumbersome (and probably slow, indexes >> be damned) though. I'm hoping there is a better way! :) > > Madison, > > I think your basic thinking is correct. However, the first "select" can > done "offline" -- sometime beforehand. > > For example, you might create a table called "keywords" that includes > the list of words mined in the other tables, along with references to > where the words are found, and how many times they are mentioned. > > Then, when someone actually searches, the search is primarily on the > "keywords" table, which is now way to sort by "rank", since the table > contains how many times each keyword matches. The final result can be > constructed by using the details in the keywords table to pull up the > actual records needed. > > My expectation however is that there are enough details in the system, > that I would first look at trying a package like tsearch2 to help solve > the problem, before trying to write another system like this from scratch. > > Mark Now see, this is exactly the kind of sagely advice I was hoping for! :) I'll look into tsearch2, and failing that for some reason, I love the keyword table idea. Thanks kindly!! Madi