From e7f2cb7f7b5f164632a2c6724610a6dbfed8a758 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Thu, 5 Apr 2007 13:51:16 +0000 Subject: [PATCH] More cleanups of tsearch2 parse query --- includes/SearchPostgres.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php index 3562b3cbf4..daebfa7130 100644 --- a/includes/SearchPostgres.php +++ b/includes/SearchPostgres.php @@ -61,6 +61,9 @@ class SearchPostgres extends SearchEngine { $term = preg_replace('/\s*\(\s*/', ' (', $term); $term = preg_replace('/\s*\)\s*/', ') ', $term); + ## Treat colons as word separators: + $term = preg_replace('/:/', ' ', $term); + $this->searchTerms = array(); $m = array(); $searchstring = ''; @@ -92,6 +95,12 @@ class SearchPostgres extends SearchEngine { ## Remove any doubled-up operators $searchstring = preg_replace('/([\!\&\|]) +(?:[\&\|] +)+/', "$1 ", $searchstring); + ## Remove any non-spaced operators (e.g. "Zounds!") + $searchstring = preg_replace('/([^ ])[\!\&\|]/', "$1", $searchstring); + + ## Remove any trailing operators + $searchstring = preg_replace('/(?: [\!\&\|])*$/', '', $searchstring); + ## Quote the whole thing $searchstring = $this->db->addQuotes($searchstring); -- 2.20.1