Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 94F4E2E0106 for ; Sat, 24 Nov 2007 15:37:02 -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 14460-02 for ; Sat, 24 Nov 2007 15:36:41 -0400 (AST) Received: from momjian.us (momjian.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 37EE02E00A0 for ; Sat, 24 Nov 2007 15:36:55 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id lAOJasT16593; Sat, 24 Nov 2007 14:36:54 -0500 (EST) From: Bruce Momjian Message-Id: <200711241936.lAOJasT16593@momjian.us> Subject: Re: Docbot search fix In-Reply-To: <473D7F4A.9030808@pjmodos.net> To: Petr Jelinek Date: Sat, 24 Nov 2007 14:36:54 -0500 (EST) CC: PostgreSQL www X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/396 X-Sequence-Number: 13174 Uh, did this get addressed? If so, I didn't see it. --------------------------------------------------------------------------- Petr Jelinek wrote: > 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) > > 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); > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq -- Bruce Momjian http://momjian.us EnterpriseDB http://postgres.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +