Volltextsuche

You have a suggestion for a future version of phpMyFAQ? Then post it here!

Moderator: Thorsten

Post Reply
0xcafeface
Posts: 1
Joined: Tue Jan 25, 2005 9:10 am

Volltextsuche

Post by 0xcafeface »

Nachdem ich es für unschön empfinde nicht eine beliebige Anzahl von Zeichen suchen zu können habe ich das SQL-Statement etwas verändert.
Mein Vorschlag wäre das für künftige Versionen zu benutzen.
Ich benutze die Version 1.4.4.

Änderung in ./inc/functions.php:

/*...*/
function searchEngine($begriff)
{
/*...*/
if (mysql_check("4.0.1") == FALSE) {
// Search with MySQL 3.23.23+
#$query = "SELECT id, lang, rubrik, thema, content FROM ".SQLPREFIX."faqdata WHERE MATCH (thema,content,keywords) AGAINST ('".$begriff."') AND active = 'yes'";


/*
---- Änderung des SQL-Statementsn
---- am 25.01.2005 von 0xcafeface vorgenommen
---- Zweck: Suchen nach Woertern kleiner als 4 Zeichen
*/
$query = "SELECT id, lang, rubrik, thema, content FROM ".SQLPREFIX."faqdata WHERE thema LIKE ('%".$begriff."%') OR content
LIKE ('%".$begriff."%') OR keywords LIKE ('%".$begriff."%') AND active = 'yes'";
/*
---- Änderung ENDE
*/



}
else {
// Search with MySQL 4.0.1+
# $query = "SELECT id, lang, rubrik, thema, content FROM ".SQLPREFIX."faqdata WHERE MATCH (thema,content,keywords) AGAINST ('".str_replace(" ", "* ", trim($begriff))."*' IN BOOLEAN MODE) AND active = 'yes'";

/*
---- Änderung des SQL-Statements
*/
$tmp_begriff = $begriff;
$tmp_begriff = '%'.$tmp_begriff.'%';
$query = "SELECT id, lang, rubrik, thema, content FROM ".SQLPREFIX."faqdata WHERE thema LIKE ('".str_replace(" ", "* ", trim($tmp_begriff))."*' IN BOOLEAN MODE) OR content LIKE ('".str_replace(" ", "* ", trim($tmp_begriff))."*' IN BOOLEAN MODE) OR keywords LIKE ('".str_replace(" ", "* ", trim($tmp_begriff))."*' IN BOOLEAN MODE) AND active = 'yes'";
/*
---- Änderung ENDE
*/
}
/*...*/

Wenn Interesse besteht poste ich gerne auch noch nen Fix für die Suche im Adminbereich.
Thorsten
Posts: 15724
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

in der 1.5 ist das optional auch mit drin.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply