From 1ac859971834b304edb71566ba2d348f31956d68 Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 10 Apr 2014 21:23:00 +0000 Subject: bug 3056: quick search - better handling of short words and photo acronyms such as AF-S EF-S X-E2 etc ... git-svn-id: http://piwigo.org/svn/trunk@28152 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_search.inc.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'include/functions_search.inc.php') diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index b3240f967..c2b3ef2d2 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -603,9 +603,15 @@ class QMultiToken $crt_token .= $ch; break; } + if (strlen($crt_token) && isdigit(substr($crt_token,0,-1)) + && $qi+1push($crt_token, $crt_modifier, $crt_scope); } @@ -822,8 +828,21 @@ function qsearch_get_text_token_search_sql($token, $fields) $fts = array(); foreach ($variants as $variant) { - if (mb_strlen($variant)<=3 - || strcspn($variant, '!"#$%&()*+,./:;<=>?@[\]^`{|}~') < 3) + $use_ft = mb_strlen($variant)>3; + if ($token->modifier & QST_WILDCARD_BEGIN) + $use_ft = false; + if (($token->modifier & QST_QUOTED|QST_WILDCARD_END) == QST_QUOTED|QST_WILDCARD_END) + $use_ft = false; + if ($use_ft) + { + $max = max( array_map( 'mb_strlen', + preg_split('/['.preg_quote('!"#$%&()*+,./:;<=>?@[\]^`{|}~','/').']+/', $variant0, PREG_SPLIT_NO_EMPTY) + ) ); + if ($max<4) + $use_ft = false; + } + + if (!$use_ft) {// odd term or too short for full text search; fallback to regex but unfortunately this is diacritic/accent sensitive $pre = ($token->modifier & QST_WILDCARD_BEGIN) ? '' : '[[:<:]]'; $post = ($token->modifier & QST_WILDCARD_END) ? '' : '[[:>:]]'; -- cgit v1.2.3