Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 181D02E2D3B for ; Fri, 16 Nov 2007 07:30:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 94456-09 for ; Fri, 16 Nov 2007 07:30:27 -0400 (AST) Received: from smtp-out4.iol.cz (smtp-out4.iol.cz [194.228.2.92]) by postgresql.org (Postfix) with ESMTP id 249E92E2368 for ; Fri, 16 Nov 2007 07:30:30 -0400 (AST) Received: from antivir6.iol.cz (unknown [192.168.30.215]) by smtp-out4.iol.cz (Postfix) with ESMTP id 5BF911C63CD for ; Fri, 16 Nov 2007 11:30:29 +0000 (UTC) Received: from localhost (antivir6.iol.cz [127.0.0.1]) by antivir6.iol.cz (Postfix) with ESMTP id 39DDD26003E for ; Fri, 16 Nov 2007 12:30:26 +0100 (CET) X-Virus-Scanned: amavisd-new at iol.cz Received: from antivir6.iol.cz ([127.0.0.1]) by localhost (antivir6.iol.cz [127.0.0.1]) (amavisd-new, port 10224) with LMTP id H9OMhfNhF3fU for ; Fri, 16 Nov 2007 12:30:26 +0100 (CET) Received: from smtp-out4.iol.cz (mta-out4 [192.168.30.31]) by antivir6.iol.cz (Postfix) with ESMTP id 0A96F26003B for ; Fri, 16 Nov 2007 12:30:26 +0100 (CET) Received: from [10.12.0.96] (51.62.broadband6.iol.cz [88.101.62.51]) by smtp-out4.iol.cz (Postfix) with ESMTP id 6082547E65 for ; Fri, 16 Nov 2007 12:30:22 +0100 (CET) Message-ID: <473D7F4A.9030808@pjmodos.net> Date: Fri, 16 Nov 2007 12:30:18 +0100 From: Petr Jelinek User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: PostgreSQL www Subject: Docbot search fix Content-Type: multipart/mixed; boundary="------------090602020000020902000007" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.098 tagged_above=0 required=5 tests=AWL=0.097, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200711/276 X-Sequence-Number: 13054 This is a multi-part message in MIME format. --------------090602020000020902000007 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Hello, there is one problem in current implementation of docbot search on pg website (the "Based on your search term, we recommend the following links" part). It only works for single words which is not how docbot is meant to work. Attached patch handles multi-word search queries the way docbot does. -- Regards Petr Jelinek (PJMODOS) --------------090602020000020902000007 Content-Type: text/plain; name="search.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="search.diff" Index: system/page/search.php =================================================================== --- system/page/search.php (revision 1813) +++ system/page/search.php (working copy) @@ -105,7 +105,15 @@ function search_docbot() { if ($this->pagenum > 1) return; // only show docbot urls on first page - $qry = "SELECT url FROM docbot_keylist WHERE \"key\" = '". pg_escape_string($this->query) ."'ORDER BY url ~ 'postgresql.org' desc, url LIMIT ". $this->maxdocbots; + // split query to separate words + $keys = preg_split('/\s+/', str_replace('"', '', $this->query)); + + // build the keyword search sql query + $part = "SELECT kurl FROM docbot_key WHERE \"key\" = lower('"; + $qry = "SELECT url FROM docbot_url WHERE id IN (\n"; + $qry .= join("\n\tINTERSECT\n", array_map(create_function('$e', 'global $part; return $part.pg_escape_string($e)."\')";'), $keys)); + $qry .= ")\nORDER BY url ~ 'postgresql.org' desc, url LIMIT ".$this->maxdocbots; + $rs = $this->pg_query($qry,'search'); for ($i = 0; $i < pg_num_rows($rs); $i++) { $r = pg_fetch_array($rs, $i, PGSQL_ASSOC); --------------090602020000020902000007--