Global search brainstorming: Difference between revisions
From MoodleDocs
Tomasz Muras (talk | contribs) No edit summary |
Tomasz Muras (talk | contribs) No edit summary |
||
| Line 2: | Line 2: | ||
{{Template:Moodle_2.3}} | {{Template:Moodle_2.3}} | ||
Global Search is a rewrite of the search mechanism for Moodle 2.3. | Global Search is a proposed rewrite of the search mechanism for Moodle 2.3. | ||
=Implementation= | |||
* Implemented using Lucene search engine (just like the original global search) | |||
* Will not require additional DB tables | |||
* Will allow for partial indexing of the content (e.g. the first time indexer is run, it may only index part of the huge site, and pick up where is left on the next run) | |||
* Will allow for indexing content from the DB and attachments (e.g. forum post & all attachments) | |||
=Modules support= | |||
Interface will need to be implemented for a module that wants to be search-able by Global Search. A module will need to: | |||
* declare that it supports FEATURE_GLOBAL_SEARCH (in function <mod>_supports). | |||
* implement 3 functions: | |||
** <mod>_gs_iterator($from = 0) | |||
** <mod>_gs_get_documents($id) | |||
** <mod>_page_gs_access($id) | |||
==<mod>_gs_iterator($from=0)== | |||
<code><pre> | |||
function forum_gs_iterator($from = 0) { | |||
global $DB; | |||
$sql = "SELECT id, modified FROM {forum_posts} WHERE modified > ? ORDER BY modified ASC"; | |||
return $DB->get_recordset_sql($sql, array($from)); | |||
} | |||
</pre></code> | |||
Revision as of 19:27, 25 October 2011
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.
Moodle 2.3
Global Search is a proposed rewrite of the search mechanism for Moodle 2.3.
Implementation
- Implemented using Lucene search engine (just like the original global search)
- Will not require additional DB tables
- Will allow for partial indexing of the content (e.g. the first time indexer is run, it may only index part of the huge site, and pick up where is left on the next run)
- Will allow for indexing content from the DB and attachments (e.g. forum post & all attachments)
Modules support
Interface will need to be implemented for a module that wants to be search-able by Global Search. A module will need to:
- declare that it supports FEATURE_GLOBAL_SEARCH (in function <mod>_supports).
- implement 3 functions:
- <mod>_gs_iterator($from = 0)
- <mod>_gs_get_documents($id)
- <mod>_page_gs_access($id)
<mod>_gs_iterator($from=0)
function forum_gs_iterator($from = 0) {
global $DB;
$sql = "SELECT id, modified FROM {forum_posts} WHERE modified > ? ORDER BY modified ASC";
return $DB->get_recordset_sql($sql, array($from));
}