-
Improvement
-
Resolution: Fixed
-
Minor
-
3.8
-
MOODLE_38_STABLE
-
MOODLE_38_STABLE
-
MDL-66326-master -
Unless you manually reindex, the global search system never deletes indexed data, other than in the case where you search for something and then get a result which has since been deleted.
For example, supposing you make a forum post containing the phrase 'bleep off'. The post gets indexed. A moderator deletes the post. Another user searches for 'bleep'. The search engine returns the post, but Moodle can't find it: the post will now be deleted from the search engine so that it isn't returned again.
If nobody had searched for words in that post (causing it to appear high enough in search results to potentially be displayed), then it would not be deleted from the index.
This is not a major problem for single forum posts, because who cares. But consider a large course with tens of thousands of forum posts. The course is now deleted. Now, not only are we wasting lots of space in the search index, it is not even possible for it to be cleared up, because searches are restricted to courses that the user can access, and no user can access the now-deleted course, so these would never show up in results.
I propose we should add new optional API to search engine, which allows for items to be deleted based on the 'courseid' field whenever a course is deleted from Moodle. (If the search engine does not support the API then it does nothing, as now.)
We can also implement this based on 'contextid' field when an activity/block is deleted,
To avoid flooding the search engine with requests, if a whole course is deleted at once, we will do the 'course' delete and suppress all 500 (or whatever) context deletes,
I did the deletes manually using the Solr interface for 11 large courses that we deleted from our live system, and caused about 300,000 search documents to be deleted from the index. That's only about 1% of our index, but every little helps! I think it's important that we have this in future so that search indexes don't grow infinitely.