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

Add restored contents support to global search API

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      Setup
      1. Setup and enable global search on your site

      h5 Testing

      1. Create a new course with default settings.
      2. Add some activities to the course, including some searchable content. This could be any searchable activity and should include at least one that is searched with the default activity search (that just does the title/description) and at least one that contains custom data within the activity such as a forum post. I suggest the following list:
        • Forum (description + a forum post)
        • Wiki (description + a wiki page)
        • Label (text)
        • Page (content, not description)
          Inside each piece of searchable content, include some text that identifies the content and a special newly-made-up word that's easy to search, like blibblesquoom.
      3. Also add an HTML block containing the word blibblesquoom (just so we can check
      4. Run the standard search indexing task (if there is a time limit and you haven't done it recently, you might need to run it multiple times until it completes). You can do this by clicking 'Run now' next to the relevant scheduled task, or using the CLI: php search/cli/indexer.php.
      5. Go to the global search form (/search/index.php). Expand 'Filter' and set the 'Courses' option to include only the course you just created. Now search for blibblesquoom.
        EXPECTED: You should see the HTML block, the forum (and other activities you created), and the forum post (and other content you created within activities) in the search results. This is existing behaviour.
      6. Create a backup of the course with default settings, and restore it to a new course. Change the name of the new course so you can clearly distinguish it.
      7. Go back to global search and change the 'Courses' option to search the newly-restored course, and search for blibblesquoom.
        EXPECTED: No results yet as the index has not yet run.
      8. Run indexing via the scheduled task or CLI. This time, look at the log output.
        EXPECTED:  You should notice a second indexing section after the main indexing, headed 'Indexing requested context: Course: (name of your new course)'.
      9. Redo the query that previously got no results.
        EXPECTED: You should now see results (the same as when searching the original course, except obviously the links should take you to the new course).
      10. Create another new course with default settings.
      11. In this course, use the 'Import' option and choose the first course you made.
      12. Leave on blocks and modules, and go to next page.
      13. Select none, and tick one or more specific activities to restore (and their section); continue and perform the import.
      14. Run indexing. This time you should see two headings (or more depending on what activities you included) below the normal search indexing log:
        Indexing requested context: Block: HTML
        Indexing requested context: Forum: (name)
      15. Do a search, selecting only the newly created course.
        EXPECTED: You should see the same results from block and activities.
      16. Open one of the courses
      17. Duplicate the Page activity
      18. Do a search for something within that content, filtering on that specific course
        1. *Confirm that you only see results for that one page (and any other valid matches)
      19. Run the indexing task
        1. Confirm that only the Page activity was re-indexed
        2. Confirm that the Course as a whole was not re-indexed
      20. Re-run the search
        1. *Confirm that you now see results for both the source page, and its duplicate (and any other valid matches)
      Show
      Setup Setup and enable global search on your site h5 Testing Create a new course with default settings. Add some activities to the course, including some searchable content. This could be any searchable activity and should include at least one that is searched with the default activity search (that just does the title/description) and at least one that contains custom data within the activity such as a forum post. I suggest the following list: Forum (description + a forum post) Wiki (description + a wiki page) Label (text) Page (content, not description) Inside each piece of searchable content, include some text that identifies the content and a special newly-made-up word that's easy to search, like blibblesquoom. Also add an HTML block containing the word blibblesquoom (just so we can check Run the standard search indexing task (if there is a time limit and you haven't done it recently, you might need to run it multiple times until it completes). You can do this by clicking 'Run now' next to the relevant scheduled task, or using the CLI: php search/cli/indexer.php. Go to the global search form (/search/index.php). Expand 'Filter' and set the 'Courses' option to include only the course you just created. Now search for blibblesquoom. EXPECTED: You should see the HTML block, the forum (and other activities you created), and the forum post (and other content you created within activities) in the search results. This is existing behaviour. Create a backup of the course with default settings, and restore it to a new course. Change the name of the new course so you can clearly distinguish it. Go back to global search and change the 'Courses' option to search the newly-restored course, and search for blibblesquoom. EXPECTED: No results yet as the index has not yet run. Run indexing via the scheduled task or CLI. This time, look at the log output. EXPECTED:  You should notice a second indexing section after the main indexing, headed 'Indexing requested context: Course: (name of your new course)'. Redo the query that previously got no results. EXPECTED: You should now see results (the same as when searching the original course, except obviously the links should take you to the new course). Create another new course with default settings. In this course, use the 'Import' option and choose the first course you made. Leave on blocks and modules, and go to next page. Select none, and tick one or more specific activities to restore (and their section); continue and perform the import. Run indexing. This time you should see two headings (or more depending on what activities you included) below the normal search indexing log: Indexing requested context: Block: HTML Indexing requested context: Forum: (name) Do a search, selecting only the newly created course. EXPECTED: You should see the same results from block and activities. Open one of the courses Duplicate the Page activity Do a search for something within that content, filtering on that specific course *Confirm that you only see results for that one page (and any other valid matches) Run the indexing task Confirm that only the Page activity was re-indexed Confirm that the Course as a whole was not re-indexed Re-run the search *Confirm that you now see results for both the source page, and its duplicate (and any other valid matches)
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-55356-master

      Description

      I thought we already had an issue about this, I haven't found it so I assume that I didn't create it.

      Global search is indexing contents by timestamp through get_recordset_by_timestamp(), but restored contents are using the original records timestamps so these contents are not indexed.

      This is a known limitation of Moodle 3.1 search API, the API should be extended to allow components to get records data from a list of ids (search area's itemid which is the unique identifier at search area level) so during restore we can flag activities and moodle subsystems elements that will later need to be indexed. A cron task can go through this list of items to index, execute this new search areas function (e.g. get_records_by_ids) and pass the records through get_docuement like we do with get_recordset_by_timestamp() when indexing by timestamp.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/Nov/17