[Mediawiki-l] Making search "and" by default

Brion Vibber brion at wikimedia.org
Tue Oct 16 15:39:05 UTC 2007


Dave Sigafoos wrote:
> So MySql has to mature in order to get an OR selection?

Nope... MySQL's boolean fulltext search uses an OR logical operation by
default, however this behavior is contrary to typical web search
practice and gives uselessly overbroad results in most cases.

People normally expect that adding terms to their search query will
*narrow* the result set (logical AND), whereas a logical OR *broadens*
the result set. When common words are involved, you quickly get to the
point where you get an insane number of results, very very few of which
are relevant.


MediaWiki's MySQL search module thus produces its queries using logical
AND in order to produce useful results in accordance with expectations.
(In MySQL's boolean fulltext syntax, this prepends each term with a '+'.)

If you wanted you could switch the default to OR on your wiki by hacking
a line in SearchMySQL4.php.

change:
	var $strictMatching = true;

to:
	var $strictMatching = false;

IMHO this would produce overbroad results by default; to narrow down
your searches you would have to manually prepend a + to the search terms
you wish to require, which would make it a lot harder to do typical
searches.


Alternatively you could write up some kind of query parser that would
take some desired alternate syntax (say, with the word 'OR' as an infix
operator) to produce the proper MySQL boolean fulltext query.

For more info on the boolean fulltext seach, see:
http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

-- brion vibber (brion @ wikimedia.org)



More information about the MediaWiki-l mailing list