aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_search.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2014-04-10 21:23:00 +0000
committerrvelices <rv-github@modusoptimus.com>2014-04-10 21:23:00 +0000
commit1ac859971834b304edb71566ba2d348f31956d68 (patch)
tree8e1ea25ed8d9ef7e1b278dfcb9fca497f3aab5dc /include/functions_search.inc.php
parentddb1632bf993b51e9bd22c4599dd38ee2351d4e8 (diff)
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
Diffstat (limited to 'include/functions_search.inc.php')
-rw-r--r--include/functions_search.inc.php25
1 files changed, 22 insertions, 3 deletions
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+1<strlen($q) && isdigit($q[$qi+1]))
+ {// dot between digits is not a separator e.g. F2.8
+ $crt_token .= $ch;
+ break;
+ }
// else white space go on..
default:
- if (preg_match('/[\s,.;!\?]+/', $ch))
+ if (strpos(' ,.;!?', $ch)!==false)
{ // white space
$this->push($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) ? '' : '[[:>:]]';