|
Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Simple moodle database engine. More...
Public Member Functions | |
| add_document ($document, $fileindexing=false) | |
| Adds a document to the search engine. More... | |
| add_documents ($iterator, $searcharea, $options) | |
| Loop through given iterator of search documents and and have the search engine back end add them to the index. More... | |
| area_index_complete ($searcharea, $numdocs=0, $fullindex=false) | |
| Do any area cleanup needed, and do anything to confirm contents. More... | |
| area_index_starting ($searcharea, $fullindex=false) | |
| Do anything that may need to be done before an area is indexed. More... | |
| check_latest_schema () | |
| Checks that the schema is the latest version. More... | |
| clear_query_error () | |
| Clears the current query error value. More... | |
| delete ($areaid=null) | |
| Delete all area's documents. More... | |
| delete_by_id ($id) | |
| Deletes the specified document. More... | |
| delete_index_for_context (int $oldcontextid) | |
| Simpledb supports deleting the index for a context. More... | |
| delete_index_for_course (int $oldcourseid) | |
| Simpledb supports deleting the index for a course. More... | |
| execute_query ($filters, $usercontexts, $limit=0) | |
| Prepares a SQL query, applies filters and executes it returning its results. More... | |
| file_indexing_enabled () | |
| Return true if file indexing is supported and enabled. More... | |
| get_document_classname () | |
| Gets the document class used by this search engine. More... | |
| get_plugin_name () | |
| Returns the plugin name. More... | |
| get_query_error () | |
| Returns any error reported by the search engine when executing the provided query. More... | |
| get_query_total_count () | |
| Returns the total results. More... | |
| get_supported_orders (\context $context) | |
| Obtain a list of results orders (and names for them) that are supported by this search engine in the given context. More... | |
| get_user ($userid) | |
| Returns user data checking the internal static cache. More... | |
| index_complete ($numdocs=0, $fullindex=false) | |
| Run any post indexing operations. More... | |
| index_starting ($fullindex=false) | |
| Run any pre-indexing operations. More... | |
| is_installed () | |
| It is always installed. More... | |
| is_server_ready () | |
| Checks that the required table was installed. More... | |
| optimize () | |
| Optimizes the search engine. More... | |
| record_applied_schema_version ($version) | |
| Usually called by the engine; marks that the schema has been updated. More... | |
| skip_schema_check ($skip=true) | |
| Tells the search engine to skip any time-consuming checks that it might do as part of the is_server_ready function, and only carry out a basic check that it can contact the server. More... | |
| supports_group_filtering () | |
| Checks if this search engine supports groups. More... | |
| supports_users () | |
| Checks if the search engine supports searching by user. More... | |
Static Public Member Functions | |
| static | clear_users_cache () |
| Clears the users cache. More... | |
Protected Member Functions | |
| get_course ($courseid) | |
| Returns a course instance checking internal caching. More... | |
| get_search_area ($areaid) | |
| Returns a search instance of the specified area checking internal caching. More... | |
| get_simple_query ($q) | |
| Returns the default query for db engines. More... | |
| should_skip_schema_check () | |
| For use by subclasses. More... | |
| to_document (\core_search\base $searcharea, $docdata) | |
| Returns a document instance prepared to be rendered. More... | |
| update_schema ($oldversion, $newversion) | |
| Requests the search engine to upgrade the schema. More... | |
Static Protected Attributes | |
| static stdClass[] | $cachedusers = array() |
| User data required to show their fullnames. More... | |
Simple moodle database engine.
| search_simpledb\engine::add_document | ( | $document, | |
$fileindexing = false |
|||
| ) |
Adds a document to the search engine.
This does not commit to the search engine.
| core_search::document | $document | |
| bool | $fileindexing | True if file indexing is to be used |
| bool | False if the file was skipped or failed, true on success |
Reimplemented from core_search\engine.
|
inherited |
Loop through given iterator of search documents and and have the search engine back end add them to the index.
| iterator | $iterator | the iterator of documents to index |
| searcharea | $searcharea | the area for the documents to index |
| array | $options | document indexing options |
| array | Processed document counts |
|
inherited |
Do any area cleanup needed, and do anything to confirm contents.
Return false to prevent the search area completed time and stats from being updated.
| core_search::base | $searcharea | The search area that was complete |
| int | $numdocs | The number of documents that were added to the index |
| bool | $fullindex | True if a full index is being performed |
| bool | True means that data is considered indexed |
Reimplemented in search_solr\engine.
|
inherited |
Do anything that may need to be done before an area is indexed.
| core_search::base | $searcharea | The search area that was complete |
| bool | $fullindex | True if a full index is being performed |
| void |
|
inherited |
Checks that the schema is the latest version.
If the version stored in config does not match the current, this function will attempt to upgrade the schema.
| bool|string | True if schema is OK, a string if user needs to take action |
|
inherited |
Clears the current query error value.
| void |
|
staticinherited |
Clears the users cache.
| null |
| search_simpledb\engine::delete | ( | $areaid = null | ) |
Delete all area's documents.
| string | $areaid |
| void |
Reimplemented from core_search\engine.
| search_simpledb\engine::delete_by_id | ( | $id | ) |
Deletes the specified document.
| string | $id | The document id to delete |
| void |
| search_simpledb\engine::delete_index_for_context | ( | int | $oldcontextid | ) |
Simpledb supports deleting the index for a context.
| int | $oldcontextid | Context that has been deleted |
| bool | True to indicate that any data was actually deleted |
| core_search::engine_exception |
Reimplemented from core_search\engine.
| search_simpledb\engine::delete_index_for_course | ( | int | $oldcourseid | ) |
Simpledb supports deleting the index for a course.
| int | $oldcourseid |
| bool | True to indicate that any data was actually deleted |
| core_search::engine_exception |
Reimplemented from core_search\engine.
| search_simpledb\engine::execute_query | ( | $filters, | |
| $usercontexts, | |||
$limit = 0 |
|||
| ) |
Prepares a SQL query, applies filters and executes it returning its results.
| core_search::engine_exception |
| stdClass | $filters | Containing query and filters. |
| array | $usercontexts | Contexts where the user has access. True if the user can access all contexts. |
| int | $limit | The maximum number of results to return. |
| core_search::document[] | Results or false if no results |
Reimplemented from core_search\engine.
|
inherited |
Return true if file indexing is supported and enabled.
False otherwise.
| bool |
Reimplemented in search_solr\engine.
|
protectedinherited |
Returns a course instance checking internal caching.
| int | $courseid |
| stdClass |
|
inherited |
Gets the document class used by this search engine.
Search engines can overwrite core_search::document with search_ENGINENAME\document class.
Looks for a document class in the current search engine namespace, falling back to core_search::document.
Publicly available because search areas do not have access to the engine details, core_search::document_factory accesses this function.
| string |
|
inherited |
Returns the plugin name.
| string | Frankenstyle plugin name. |
|
inherited |
Returns any error reported by the search engine when executing the provided query.
It should be called from static::execute_query when an exception is triggered.
| string |
| search_simpledb\engine::get_query_total_count | ( | ) |
Returns the total results.
Including skipped results.
| int |
Reimplemented from core_search\engine.
|
protectedinherited |
Returns a search instance of the specified area checking internal caching.
| string | $areaid | Area id |
| core_search::base |
|
protected |
Returns the default query for db engines.
| string | $q | The query string |
| array | SQL string and params list |
|
inherited |
Obtain a list of results orders (and names for them) that are supported by this search engine in the given context.
By default, engines sort by relevance only.
| context | $context | Context that the user requested search from |
| array | Array from order name => display text |
Reimplemented in search_solr\engine.
|
inherited |
Returns user data checking the internal static cache.
Including here the minimum required user information as this may grow big.
| int | $userid |
| stdClass |
|
inherited |
Run any post indexing operations.
Should be overwritten if the search engine needs to do any post index cleanup.
| int | $numdocs | The number of documents that were added to the index |
| bool | $fullindex | True if a full index was performed |
| void |
|
inherited |
Run any pre-indexing operations.
Should be overwritten if the search engine needs to do any pre index preparation.
| bool | $fullindex | True if a full index will be performed |
| void |
| search_simpledb\engine::is_installed | ( | ) |
| search_simpledb\engine::is_server_ready | ( | ) |
Checks that the required table was installed.
| true|string | Returns true if all good or an error string. |
Reimplemented from core_search\engine.
|
inherited |
Optimizes the search engine.
Should be overwritten if the search engine can optimize its contents.
| void |
Reimplemented in search_solr\engine.
|
inherited |
Usually called by the engine; marks that the schema has been updated.
| int | $version | Records the schema version now applied |
|
protectedinherited |
For use by subclasses.
The engine can call this inside is_server_ready to check whether it should skip time-consuming schema checks.
| bool | True if schema checks should be skipped |
|
inherited |
Tells the search engine to skip any time-consuming checks that it might do as part of the is_server_ready function, and only carry out a basic check that it can contact the server.
This setting is not remembered and applies only to the current request.
| bool | $skip | True to skip the checks, false to start checking again |
|
inherited |
Checks if this search engine supports groups.
Note that returning true to this function causes the parameters to execute_query to be passed differently!
In order to implement groups and return true to this function, the search engine should:
| bool | True if this engine supports searching by group id field |
Reimplemented in search_solr\engine.
|
inherited |
Checks if the search engine supports searching by user.
If it returns true to this function, the search engine should support the 'userids' option in the $filters value passed to execute_query(), returning only items where the userid in the search document matches one of those user ids.
| bool | True if the search engine supports searching by user |
Reimplemented in search_solr\engine.
|
protectedinherited |
Returns a document instance prepared to be rendered.
| core_search::base | $searcharea | |
| array | $docdata |
| core_search::document |
|
protectedinherited |
Requests the search engine to upgrade the schema.
The engine should update the schema if possible/necessary, and should ensure that record_applied_schema_version is called as a result.
If it is not possible to upgrade the schema at the moment, it can do nothing and return; the function will be called again next time search is initialised.
The default implementation just returns, with a DEBUG_DEVELOPER warning.
| int | $oldversion | Old schema version |
| int | $newversion | New schema version |
| bool|string | True if schema is updated successfully, a string if it needs updating manually |
Reimplemented in search_solr\engine.
|
staticprotectedinherited |
User data required to show their fullnames.
Indexed by userid.