Author: blentz
Description:
hack to add double quote search phrase functionality
I have a pool of users who are nervous to adopt our MediaWiki installation as a corporate document repository due to a problem using search phrases. Our user community wishes to enter double-quote enclosed search strings to search for multiple works that are adjacent to each other, instead of entering multiple search terms which all may exist separately in different parts of the document.
I was surprised to find on the http://www.mediawiki.org/wiki/Help:Searching and http://en.wikipedia.org/wiki/Help:Searching pages that this isn't a supported function:
Even if you enclose a phrase in quotes, the search looks for each word individually. e.g. if you enter "world war 2" it will return pages that contain "world" and "war" and "2".
Phrase: There is no method for searching for a phrase. Contrary to what you might expect, enclosing phrases in double quotation marks such as "can of tuna" will retrieve all pages containing "of" "tuna" and "can".
I was even more surprised when I realized that my installation had full text support in MySQL 4.1+, using the Boolean Full-Text Searches option. From http://dev.mysql.com/doc/refman/4.1/en/fulltext-boolean.html:
A phrase that is enclosed within double quote (‘"’) characters matches only rows that contain the phrase literally, as it was typed.
Though some digging, I found that MediaWiki is actually stripping the double-quote characters out, even though the user performing the search intended to have them in place and the underlying database search functions support it.
I have hacked together a patch to make this work for the user community, but it's got some limitations (obvious upon review to those who know the code). If there's any chance that search phrases will be implemented in a future version of MediaWiki, please let me know. Our user base thinks they've got a real need for this feature.
Thanks in advance
Version: 1.10.x
Severity: enhancement
Attached: