diff options
Diffstat (limited to 'inc/fulltext.php')
-rw-r--r-- | inc/fulltext.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php index fd974c949..e8b31b201 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -49,6 +49,15 @@ function ft_pageSearch($query,&$poswords){ $hidden = array_filter(array_keys($docs),'isHiddenPage'); $not = array_merge($not,$hidden); + // filter unmatched namespaces + if(!empty($q['ns'])) { + foreach($docs as $key => $val) { + if(!preg_match('/^'.$q['ns'].'/',$key)) { + unset($docs[$key]); + } + } + } + // remove negative matches foreach($not as $n){ unset($docs[$n]); @@ -254,10 +263,17 @@ function ft_queryParser($query){ $q = array(); $q['query'] = $query; + $q['ns'] = ''; $q['phrases'] = array(); $q['and'] = array(); $q['not'] = array(); + // strip namespace from query + if(preg_match('/([^@]*)@([^@]*)/',$query,$match)) { + $query = $match[1]; + $q['ns'] = $match[2]; + } + // handle phrase searches while(preg_match('/"(.*?)"/',$query,$match)){ $q['phrases'][] = $match[1]; |