From: Greg Sabino Mullane Date: Fri, 27 Apr 2007 03:45:43 +0000 (+0000) Subject: Defer populating searchTerms until later on - allows for better highlighting. X-Git-Tag: 1.31.0-rc.0~53209 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=0ccdb6c085b8c9cd40b3c5a30136ca1f56dbc1b3;p=lhc%2Fweb%2Fwiklou.git Defer populating searchTerms until later on - allows for better highlighting. --- diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php index 2589e70ecc..3a624cede3 100644 --- a/includes/SearchPostgres.php +++ b/includes/SearchPostgres.php @@ -63,8 +63,6 @@ class SearchPostgres extends SearchEngine { ## Treat colons as word separators: $term = preg_replace('/:/', ' ', $term); - $this->searchTerms = array(); - $m = array(); $searchstring = ''; if( preg_match_all('/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) { foreach( $m as $terms ) { @@ -82,9 +80,6 @@ class SearchPostgres extends SearchEngine { } else { $searchstring .= " & $terms[2]"; - $safeterm = preg_replace('/\W+/', '', $terms[2]); - if (strlen($safeterm)) - $this->searchTerms[$safeterm] = $safeterm; } } } @@ -138,6 +133,13 @@ class SearchPostgres extends SearchEngine { "AND r.rev_text_id = c.old_id AND 1=0"; } else { + $m = array(); + if( preg_match_all("/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) { + foreach( $m as $terms ) { + $this->searchTerms[$terms[1]] = $terms[1]; + } + } + $query = "SELECT page_id, page_namespace, page_title, ". "rank($fulltext, to_tsquery('default',$searchstring),5) AS score ". "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .