From a219c1f00349b720d262939fec3e7baf19a63402 Mon Sep 17 00:00:00 2001 From: "Michael Klier chi@chimeric.de" <andi@splitbrain.org> Date: Thu, 18 May 2006 22:46:47 +0200 Subject: [PATCH] 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 --- inc/fulltext.php | 9 +++++---- 1 file 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 -- GitLab