From 8c80fe0bf51fa472ddf9bf225490e47ea1bf4a7f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 20 May 2012 00:11:32 +0200 Subject: Performance tests --- mod/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index e59839ccc..c5347756c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -413,7 +413,7 @@ function network_content(&$a, $update = 0) { $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%s' . $myurl)), + dbesc(protect_sprintf('%' . $myurl)), dbesc(protect_sprintf('%' . $myurl . '\\]%')), dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) ); -- cgit v1.2.3 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/network.php | 18 +++++++++++++----- mod/search.php | 16 +++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index c6f683b93..f54d055d3 100644 --- a/mod/network.php +++ b/mod/network.php @@ -416,11 +416,19 @@ function network_content(&$a, $update = 0) { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . '\\]%')), - dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) - ); + if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . '\\]%')), + dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) + ); + } 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/network.php | 20 ++++++++++++++++---- mod/search.php | 3 +-- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index f54d055d3..6b4fa9a5b 100644 --- a/mod/network.php +++ b/mod/network.php @@ -402,10 +402,22 @@ function network_content(&$a, $update = 0) { if(x($_GET,'search')) { $search = escape_tags($_GET['search']); - $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", - dbesc(protect_sprintf('%' . $search . '%')), - dbesc(protect_sprintf('%]' . $search . '[%')) - ); + if (get_config('system','use_fulltext_engine')) { + if(strpos($search,'#') === 0) + $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + dbesc(protect_sprintf($search)) + ); + else + $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + dbesc(protect_sprintf($search)), + dbesc(protect_sprintf($search)) + ); + } else { + $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", + dbesc(protect_sprintf('%' . $search . '%')), + dbesc(protect_sprintf('%]' . $search . '[%')) + ); + } } if(strlen($file)) { $sql_extra .= file_tag_file_query('item',unxmlify($file)); 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