r34073 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34072‎ | r34073 | r34074 >
Date:13:37, 1 May 2008
Author:rainman
Status:old
Tags:
Comment:
* Add a switch for overriding the default prefix search backend.
* Make term extraction a bit smarter
Modified paths:
  • /trunk/extensions/MWSearch/MWSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MWSearch/MWSearch.php
@@ -39,15 +39,22 @@
4040 # - it's in the 'lucene-search' and 'mwsearch' modules in CVS.
4141 ##########
4242
43 -# If to show related links (if available) below search results
44 -$wgLuceneUseRelated = true;
4543
4644 # Back-end version (override before including MWSearch.php)
4745 if( !isset($wgLuceneSearchVersion) )
4846 $wgLuceneSearchVersion = 2;
 47+
 48+# If to show related links (if available) below search results
 49+if( !isset($wgLuceneUseRelated) )
 50+ $wgLuceneUseRelated = false;
 51+
 52+# If to use lucene as a prefix search backend
 53+if( !isset($wgEnableLucenePrefixSearch) )
 54+ $wgEnableLucenePrefixSearch = false;
 55+
4956 # For how long (in seconds) to cache lucene results, off by default (0)
5057 # NOTE: caching is typically inefficient for queries, with cache
51 -# hit rates way below 1% even for very long expiry times
 58+# hit rates way below 1% even for very long expiry times
5259 if( !isset($wgLuceneSearchCacheExpiry) )
5360 $wgLuceneSearchCacheExpiry = 0;
5461
@@ -64,7 +71,7 @@
6572 );
6673 $wgExtensionMessagesFiles['MWSearch'] = dirname(__FILE__) . '/MWSearch.i18n.php';
6774
68 -if($wgLuceneSearchVersion >= 2.1)
 75+if($wgLuceneSearchVersion >= 2.1 && $wgEnableLucenePrefixSearch)
6976 $wgHooks['PrefixSearchBackend'][] = 'LuceneSearch::prefixSearch';
7077
7178 function wfLuceneSearch() {
@@ -676,7 +683,7 @@
677684 function termMatches() {
678685 $resq = preg_replace( "/\\[.*?\\]:/", " ", $this->mQuery ); # generic prefixes
679686 $resq = preg_replace( "/all:/", " ", $resq );
680 - $resq = trim( preg_replace( "/[ |\\[\\]()\"{}+]+/", " ", $resq ) );
 687+ $resq = trim( preg_replace( "/[ |\\[\\]()\"{}+\\-_@!?%&*=\\|:;><,.\\/]+/", " ", $resq ) );
681688 $terms = array_map( array( &$this, 'regexQuote' ),
682689 explode( ' ', $resq ) );
683690 return $terms;

Status & tagging log