diff options
author | Michael Klier chi@chimeric.de <andi@splitbrain.org> | 2006-05-18 22:46:47 +0200 |
---|---|---|
committer | Michael Klier chi@chimeric.de <andi@splitbrain.org> | 2006-05-18 22:46:47 +0200 |
commit | a219c1f00349b720d262939fec3e7baf19a63402 (patch) | |
tree | 2584d6b3873be5a1062538903522c922b57bd43d | |
parent | d0ab54f6197249cebc808395ab9de9da0df153f3 (diff) | |
download | rpg-a219c1f00349b720d262939fec3e7baf19a63402.tar.gz rpg-a219c1f00349b720d262939fec3e7baf19a63402.tar.bz2 |
namespace-restricted fulltext-search part2
- now its possible to restrict the fulltext-search to
multible namespaces
Examples:
searchword @ns1 @ns2 @ns3
"exact phrase" @ns1 @ns2 @ns3
darcs-hash:20060518204647-484ab-061521a81f13360e33496e5163e3cd263a9c1ad6.gz
-rw-r--r-- | inc/fulltext.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php index e8b31b201..7702711f5 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -51,8 +51,9 @@ function ft_pageSearch($query,&$poswords){ // filter unmatched namespaces if(!empty($q['ns'])) { + $pattern = implode('|^',$q['ns']); foreach($docs as $key => $val) { - if(!preg_match('/^'.$q['ns'].'/',$key)) { + if(!preg_match('/^'.$pattern.'/',$key)) { unset($docs[$key]); } } @@ -263,15 +264,15 @@ function ft_queryParser($query){ $q = array(); $q['query'] = $query; - $q['ns'] = ''; + $q['ns'] = array(); $q['phrases'] = array(); $q['and'] = array(); $q['not'] = array(); // strip namespace from query - if(preg_match('/([^@]*)@([^@]*)/',$query,$match)) { + if(preg_match('/([^@]*)@(.*)/',$query,$match)) { $query = $match[1]; - $q['ns'] = $match[2]; + $q['ns'] = explode('@',preg_replace("/ /",'',$match[2])); } // handle phrase searches |