Loading...
 

MySQL4searchHack

reason:

  • achieve the following search functionality:
    • quoted multiple-word strings return hits only when entire string is matched
    • boolean search syntax +wordA +wordB returns only objects which contain both words
    • boolean search syntax +wordA -wordB returns only hits which contain wordA but not wordB


changed file:

  • lib/searchlib.php


notes:

  • this hack is only intended for MySQL 4.0+
  • this does not involve the "Search-new" Tiki search engine


1) Add Boolean clause to SELECT statement:


$sqlft = 'MATCH(' . join(',', $h['search']). ') AGAINST (' . $qwords . ')';


$sqlft = 'MATCH(' . join(',', $h['search']). ') AGAINST (' . $qwords;

global $db_tiki;

if ($db_tiki='mysql') {
$sqlft .= ' IN BOOLEAN MODE)';
} else {
$sqlft .= ' )';
}

2) Remove Simple Search fallback:


if (!$cant) { // no result
if ($fulltext && $words) // try a simple search
return $this->_find($h, $words, $offset, $maxRecords, false);
else
return array(
'data' => array(),
'cant' => 0
);
}


note: the simple search block causes following error in MySQL 4.0.15 boolean search "+listening +page":
Warning: mysql error: Got error 'repetition-operator operand invalid' from regexp in query:

SELECT COUNT(*) FROM tiki_comments c, tiki_pages p WHERE c.objectType = "wiki page"
AND p.pageName=c.object AND (UPPER(c.title) REGEXP '.*+LISTENING.*'
OR UPPER(c.data) REGEXP '.*+LISTENING.*') AND (UPPER(c.title) REGEXP '.*+PAGE.*'
OR UPPER(c.data) REGEXP '.*+PAGE.*')

in c:\program files\easyphp1-7\www\tw\lib\tikidblib.php on line 125
Values:

$result is false
$result is empty



Unless I'm missing something, the Tiki.org search engine doesn't work as expected either. Quoted strings just act like simple ORs and boolean +/- prefixes cause lots of error messages. I had the same symptoms on my 1.8 implementation until I made these changes.''


I will attach modified source code snippet and Unix diff file.


Page last modified on Monday 19 March 2018 07:56:36 GMT-0000

Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting