-
Improvement
-
Resolution: Unresolved
-
Major
-
None
-
3.9.18, 4.0.5, 4.1
-
MySQL
-
MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
When using MySQL (MariaDB), the forum search function allows partial word searches, but the global search function does not allow partial word searches.
Testing Instructions:
- Login as Site admin.
- Go to "Dashboard > Site administration > Adbanced features".
- Check "Enable global search enableglobalsearch".
- Press "Save changes".
- Go to a certain course (eg. MDL001).
- Press "Turn editing on".
- Add the "Global search" block.
- Add a Page resource (Name="Moodle", Content="Moodle is a free, online Learning Management system enabling educators to create their own private website filled with dynamic courses that extend learning, any time, anywhere.").
- Press "Save and return to course".
- Add a Forum activity (Name="Forum001" Forum type="Standard forum for general use").
- Press "Save and return to course".
- Press "Turn editing off".
- Go to the "Forum001".
- Press "Add discussion topic".
- Type in Subject and Message (Subject="Moodle", Message="Whether you're a teacher, student or administrator, Moodle can meet your needs. Moodle’s extremely customisable core comes with many standard features. )."
- Press "Post to forum".
- Go to "Dashboard > Site administration > Plugins > Search > Manage global search".
- Press "4. Index data".
- Press "Reindex all site contents".
- Press "Confirm".
- Go back to the course (MDL001).
- Type in "Manage" on the textbox on "Global search" block.
- Press Search (magnifying glass) icon.
- Type in "extreme" on the textbox on "Global search" block.
- Press Search (magnifying glass) icon.
Solution:
We can modify the related program file as below.
Program file to modify:
search/engine/simpledb/classes/engine.php
Line:
146
[ Before ]
case 'mysql':
if ($DB->is_fulltext_search_supported()) {
$ands[] = "MATCH (title, content, description1, description2) AGAINST ";
$params[] = $filters->q;
// Sorry for the hack, but it does not seem that we will have a solution for
// this soon (https://bugs.mysql.com/bug.php?id=78485).
if ($filters->q === '*')
[ After ]
case 'mysql':
if ($DB->is_fulltext_search_supported()) {
// $ands[] = "MATCH (title, content, description1, description2) AGAINST ";
$ands[] = "(" .
"(title REGEXP ?) OR ".
"(content REGEXP ?) OR".
"(description1 REGEXP ?) OR ".
"(description2 REGEXP ?)".
")";
$params[] = $filters->q;
$params[] = $filters->q;
$params[] = $filters->q;
$params[] = $filters->q;
// Sorry for the hack, but it does not seem that we will have a solution for
// this soon (https://bugs.mysql.com/bug.php?id=78485).
if ($filters->q === '*') { return array(); }
- will help resolve
-
MDL-70225 Moodle global search not working correctly
-
- Open
-