Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-76533

Allow partial word searches in the global search block when using MySQL

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 3.9.18, 4.0.5, 4.1
    • Global search

      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:

      1. Login as Site admin.
      2. Go to "Dashboard > Site administration > Adbanced features".
      3. Check "Enable global search enableglobalsearch".
      4. Press "Save changes".
      5. Go to a certain course (eg. MDL001).
      6. Press "Turn editing on".
      7. Add the "Global search" block.
      8. 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.").
      9. Press "Save and return to course".
      10. Add a Forum activity (Name="Forum001" Forum type="Standard forum for general use").
      11. Press "Save and return to course".
      12. Press "Turn editing off".
      13. Go to the "Forum001".
      14. Press "Add discussion topic".
      15. 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. )."
      16. Press "Post to forum".
      17. Go to "Dashboard > Site administration > Plugins  > Search > Manage global search".
      18. Press "4. Index data".
      19. Press "Reindex all site contents".
      20. Press "Confirm".
      21. Go back to the course (MDL001).
      22. Type in "Manage" on the textbox on "Global search" block.
      23. Press Search (magnifying glass) icon.
      24. Type in "extreme" on the textbox on "Global search" block.
      25. 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 === '*')

      {                             return array();                         }

      [ 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();                         }

       

       

            Unassigned Unassigned
            mits Mitsuhiro Yoshida
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.