From 49512105082dde72553f4250e6284920612cc6b8 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 03:21:07 +0200 Subject: Speed optimisation by enabling the posibility of the MySQL fulltext engine --- mod/search.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 3e6bf68aa..ac5134696 100644 --- a/mod/search.php +++ b/mod/search.php @@ -109,11 +109,17 @@ function search_content(&$a) { if(! $search) return $o; - if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); - else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); - + if (get_config('system','use_fulltext_engine')) { + if($tag) + $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.preg_quote($search)); + else + $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(preg_quote($search))); + } else { + if($tag) + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + } -- cgit v1.2.3 From a5dc41ab131d4235eb947ff00d7af0593bf0e460 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 11:51:48 +0200 Subject: Saved searches now can search for tags as well --- mod/search.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index ac5134696..d4cd9d967 100644 --- a/mod/search.php +++ b/mod/search.php @@ -71,7 +71,7 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } - + nav_set_selected('search'); require_once("include/bbcode.php"); @@ -96,7 +96,6 @@ function search_content(&$a) { $o .= search($search,'search-box','/search',((local_user()) ? true : false)); - if(strpos($search,'#') === 0) { $tag = true; $search = substr($search,1); -- cgit v1.2.3