From d0ab54f6197249cebc808395ab9de9da0df153f3 Mon Sep 17 00:00:00 2001 From: "Michael Klier chi@chimeric.de" Date: Thu, 18 May 2006 18:18:55 +0200 Subject: namespace restricted fulltext-search - The fulltext-search can now be restricted to a given namespace seperated by an "@" darcs-hash:20060518161855-484ab-1617b6d2c3593525f4d29a789b0a32ebf414b9ae.gz --- inc/fulltext.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'inc/fulltext.php') 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]; -- cgit v1.2.3