]> git.mxchange.org Git - friendica.git/blobdiff - mod/search.php
Speed optimisation by enabling the posibility of the MySQL fulltext engine
[friendica.git] / mod / search.php
index 3e6bf68aa679c96c1aaaa3507e3c00cc261e3ae3..ac51346963bbde408520a8b8168fb0206b04c2c1 100644 (file)
@@ -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)));
+       }