Revision [16753]
This is an old revision of Mod029fImprovedSearch made by HphBt0 on 2007-05-31 10:44:31.
Wikka Mod 029
Type: Feature AdditionCredit:
pmyatt -- for the original idea and function code.Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.
This will search for partial matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.
Here is the function I added in wakka.php:
function FullTextSearchAndLikeTags($phrase) { return $this->LoadAll(" (select * from ".$this->config["table_prefix"] ."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase) ."%')) UNION (select * from ".$this->config["table_prefix"] ."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))"); }
Then I modified actions/textsearch.php and actions/textsearchexpanded.php to use the new function.
Alternative way to do it
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
{ $data = $this->LoadAll("select * from " .$this->config["table_prefix"] ."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase) ."' IN BOOLEAN MODE) order by time DESC"); }
To:
{ $data = $this->LoadAll(" select * from " .$this->config["table_prefix"] ."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from " .$this->config["table_prefix"] ."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase) ."' IN BOOLEAN MODE) order by time DESC"); }
--pmyatt
Great, thanks. This will be added to version 1.1.5.4. -- JsnX