Help talk:Searching

Phase matching
Why doesn't the search support phases? At the very least the search should return pages containing ALL the words first. The search functionality is inadequate.

At some point I plan to replace the Mediawiki built-in search with something that supports phase matching.

24.128.140.97 - 16:40, 10 April 2007

change Stopwords?
is it possible, to change the stopwords on a local wiki? Where can I find the stopwordlist? --141.113.86.23 16:26, 26 April 2007 (UTC)


 * I found them in the file mysqld-opt.exe, but that does not seem to be directly editable.--Patrick 09:39, 29 April 2007 (UTC)

Wildcard Search
What is the recommended approach of adding wildcard search. E.g. I would like to get the following to work Rab* would return Rabbi, Rabbit, Rabbits etc.... Many thanks --Markw21 12:32, 8 May 2007 (UTC)


 * Yes, like that, rab*. The asterisk seems to work only at the end of a word.--Patrick 12:51, 8 May 2007 (UTC)


 * Thanks Patrick, but it does not seem to work for me, I specifically have a document called Outages, but when I search for Outage or Outage* it does not find the document. (Mediawiki 1.9.2, PHP 5.2.1, MySQL 5.0.37) --Markw21 12:54, 8 May 2007 (UTC)


 * I see now that you need to install the extension lucene search.--Patrick 15:40, 8 May 2007 (UTC)


 * Is there anyway I can get wildcard searching working without having to install lucene, c#, mono, mcs. There seems to be various different methods, and I would like to pick an 'easy', commonly adopted method, that will not be broken by future releases of mediawiki.


 * Yes! Create a new file in include/ named SearchMySQL4SubString.php with following content:

db =& $db; }

function legalSearchChars { return "A-Za-z_'0-9\\x80-\\xFF\\-*?+"; }

/** @todo document */ function parseQuery( $filteredText, $fulltext ) { global $wgContLang; $lc = SearchEngine::legalSearchChars; $searchon = ''; $this->searchTerms = array;

wfDebug( "parseQuery filteredText is: '$filteredText'\n" ); wfDebug( "parseQuery fulltext is: '$fulltext'\n" );

# FIXME: This doesn't handle parenthetical expressions. if( preg_match_all( '/([-+<>~]?)((['. $lc. ']+)(\*?)|"[^"]*")/',                   $filteredText, $m, PREG_SET_ORDER ) ) {                  foreach( $m as $terms ) {                        if( $searchon !==  ) $searchon .= ' ';                        $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );                        if( !empty( $terms[3] ) ) {                              $regexp = preg_quote( $terms[3], '/' );                              if( $terms[4] ) $regexp .= "[0-9A-Za-z_]+";                        } else {                              $regexp = preg_quote( str_replace( '"', , $terms[2] ), '/' ); }                       $this->searchTerms[] = $regexp; }                 wfDebug( "Would search with '$searchon'\n" ); wfDebug( "Match with /\b" . implode( '\b|\b', $this->searchTerms ) . "\b/\n" ); } else { wfDebug( "Can't understand search query '{$this->filteredText}'\n" ); }

$searchon = $this->db->strencode( $searchon ); $field = $this->getIndexField( $fulltext ); return " MATCH($field) AGAINST('$searchon' IN BOOLEAN MODE) "; } } ?>
 * Then add following lines in your LocalSettings.php

require_once( 'SearchMySQL4SubString.php' ); $wgSearchType = 'SearchMySQL4SubString';


 * And yes, it works with MySQL5 :)

--213.214.18.64 09:52, 10 May 2007 (UTC)

Many thanks that works great, if there anyway to get it to always add the *, so the user wouldn't have to? --Markw21 11:43, 10 May 2007 (UTC)


 * Oh yes, you can change the function searchText in the SearchMySQL.php like that

function searchText( $term ) { $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ).'*', true ) ) ); return new MySQLSearchResultSet( $resultSet, $this->searchTerms );
 * So the * is in the sourcecode and doesn't need to be inserted manually.
 * --213.214.18.64 12:27, 10 May 2007 (UTC)

Searchresults - jump to result by link
Is it possible to jump directly to a result found in a text? For example: I search for "computer", my result is a page where "computer" appears 200 times. The result I need is in line 1534. Can mediawiki create a link direct to this line in the text? --213.214.18.64 10:12, 10 May 2007 (UTC)


 * This would be nice for page history differences that involve particular sections; having direct links to the section(s) would be nice instead of having to scroll down on particularly long pages (like talk pages) in order to see the actual text. -Eep² 03:19, 25 July 2007 (UTC)

Blank page after upgrade to 1.10
after upgrading to v1.10, this code gives me php errors and a blank page.

The error I get is:

[17-May-2007 13:07:34] PHP Fatal error: Cannot make static method SearchEngine::legalSearchChars non static in class SearchMySQL4SubString in C:\www\doc\includes\SearchMySQL4SubString.php on line 15

anyone know how to fix this? --Dingfelder 01:10, 17 May 2007 (UTC)
 * is there really a SearchMySQL4SubString.php in your include dir? this php is no standard and maybe you have to ceate it on your own --213.214.18.64 06:40, 21 May 2007 (UTC)


 * please read the instructions above for adding the wild card search... they specify to create this file and show it's contents. The reason I am posting is this code is now causing the problem after the upgrade     --Dingfelder 05:15, 22 May 2007 (UTC)

I do not really know, why it works, but it works on my wiki (1.10) after changing the line (in the extension)

"function legalSearchChars {"

to

"public static function legalSearchChars {"

Update for 1.1X
It's also working with 1.11 :) Thank you work that great work!!!

Line 23: "function legalSearchChars {" -> "public static function legalSearchChars {"

--213.214.18.64 13:42, 27 September 2007 (UTC)

Search for short word or abbreviations
Is it possible to make search also search world like "lvm". I got one article with word lvm in it but it gives me 0 results. However when I search for "logical" I get desired page. I'm 100% sure that everyone will search lvm not "logical volume manager". thank you

3 character search?
I have just discovered that the search function does not give any results on words that have less than 4 characters. Is there a way to change that?

Hans Telgen 07:27, 6 July 2007 (UTC)


 * The answer is in the FAQ here. 199.67.140.153 14:32, 25 July 2007 (UTC)

Search statistics
Is there a way to see what users are searching for? Some kind of statistics. thank you
 * eek! would be awesome. --Subfader 09:11, 9 April 2008 (UTC)

Searching for Words with ä, ö and ü in it
We do administrate a German wiki using the MediaWiki-Software. When we post articles with the letters Ä, Ö or Ü in the title the search ever show an Error: "Ungültiger Titel". How can I fix this? --Ulli1105 10:33, 12 February 2008 (UTC)

[RESOLVED] Go for other namespaces
I'd like the Go feature working for other namespaces, e.g. I enter "House" the Go button will take me to Category:House (if exists). It could be combined with the ns you define as default in your user prefs. --Subfader 19:51, 28 February 2008 (UTC)
 * Solved for me by: Extension talk:GoToCategory --Subfader 09:10, 9 April 2008 (UTC)

Quote problems
While I search for something like "O'Leary" it'll end up with 404 page :( Has anyone a fix for the quote ( ' ), so that it won't break my Mediawiki?