aboutsummaryrefslogtreecommitdiffstats
path: root/mod/search.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-04-05 06:27:40 -0700
committerFriendika <info@friendika.com>2011-04-05 06:27:40 -0700
commitee19746aa9a4cff0ef5f83de6b6d9ecceee513d6 (patch)
treec8e3d999c1fbc193f1287a46dc5c31c863d3d9cc /mod/search.php
parent4c5e091b784574337c7124b7763bbd19f4bc810f (diff)
downloadvolse-hubzilla-ee19746aa9a4cff0ef5f83de6b6d9ecceee513d6.tar.gz
volse-hubzilla-ee19746aa9a4cff0ef5f83de6b6d9ecceee513d6.tar.bz2
volse-hubzilla-ee19746aa9a4cff0ef5f83de6b6d9ecceee513d6.zip
revert to regex search when < 3 chars
Diffstat (limited to 'mod/search.php')
-rw-r--r--mod/search.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/mod/search.php b/mod/search.php
index 64281dfcf..b53bd45c0 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -36,12 +36,20 @@ function search_content(&$a) {
AND `item`.`deny_gid` = ''
";
+ $s_bool = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )";
+ $s_regx = "AND `item`.`body` REGEXP '%s' ";
+
+ if(mb_strlen($search) >= 3)
+ $search_alg = $s_bool;
+ else
+ $search_alg = $s_regx;
+
$r = q("SELECT COUNT(*) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
AND ( `wall` = 1 OR `contact`.`uid` = %d )
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
+ $search_alg
$sql_extra ",
intval(local_user()),
dbesc($search)
@@ -65,7 +73,7 @@ function search_content(&$a) {
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
AND ( `wall` = 1 OR `contact`.`uid` = %d )
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
+ $search_alg
$sql_extra
ORDER BY `parent` DESC ",
intval(local_user()),