Thanks to various HQ developers for reviewing and integrating the
code, the two global search improvements I developed so far have made it
into Moodle 3.4. (Allowing block search MDL-58957; supporting partial
As we move towards implementing global search in our Moodle-based VLE, there are more improvements I'd like to put in, and before I start I thought I'd post about them here to see if anyone has opinions.
(By the way I wonder if not too many people are actually using global search, or not on a large scale? It's actually a really nice feature and seems to work quite well, albeit there are some problems with it. And it's pretty easy to set up an Apache Solr server, or you can pay somebody to host it for you.)
Here are the things I'd like to implement - I will create tracker issues and so on when I'm ready to work on these (except there's one I already set up in a sort of half-arsed effort to see how easy it was, turned out not very).1. A Behat step to mock search results for testing the UI (I already mentioned this last thread)
2. The ability to search courses you are not enrolled in
This is a complicated one. Currently the system only lets you search courses you are enrolled in, but in our VLE, there are some courses students can access even if not enrolled (using moodle/course:view). And we will have custom search UI to search only the current course. It would be nice if it works on those courses.
The obvious solution would be to make it possible to search all courses you can access even if not enrolled, but this could cause a large expansion in the number of contexts users can access (problem because of MDL-54992) and might be difficult for other reasons too.
What I'm thinking instead is simply to make it possible from the back end so that if you supply a list of courses to search, then it will include all those courses if you have access to them, even if you aren't enrolled. There are probably some details that need working out. Anyhow, this way it won't increase the number of contexts in a 'full' search...
3. Group-aware searching (already filed as MDL-58885)
Supposing you have 50 tutor groups and a tutor group forum with lots of posts, set to 'separate groups' mode. Currently, if a user searches for something that is mentioned in the forum, it will return all the results regardless of group, and then filter out results the user can't see - on average, 98% of results will be filtered out. This is really inefficient.
Also it would be nice if you can search for only results in a specific group.
Neither thing is possible because at the moment, group IDs are not passed to Solr or other search engines along with the other document metadata. I'd like to change this. I don't see a fundamental reason why it shouldn't work... It might be quite hard though, I didn't finish figuring it out.
4. Ability to search a single context
Our current in-house search system lets you search, for example, just in the current forum. At the moment there isn't a way to do this in the search API, you can only search a whole course. There's no fundamental reason why this shouldn't be possible, it should be quite easy to add. (I'm proposing adding the back-end for it, not necessarily a user interface.)
5. Ability to search by user
The search API already stores the user id of people who created a search document, but there's no way to use that for searching - it would be nice if you could search for 'posts by my mate Anthea that include the word asbestos', for instance. Again this should be reasonably feasible to add.
6. Use one server to search, another to index
If you have a large system and you want to switch between search servers (e.g. changing provider), you need to reindex on the new server, which might take many hours. It would be nice if there was a way to keep using the existing server (albeit with an out of date index) at the same time as indexing on the new one.
That's it. Anyone else interested in any of these? Some of them seem to me like pretty basic things that are missing from the API.