Revision [2584]

This is an old revision of Mod029fImprovedSearch made by PolVazo on 2004-11-28 19:29:02.

 

Wikka Mod 029

Type: Feature Addition

Credit:

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
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki