- 06 Aug 2024
- 2 minutes to read
Full text search
- Updated on 06 Aug 2024
- 2 minutes to read
Full text search (FTS) allows a sophisticated approach to text search in Totara, particularly within the catalogue.
Instead of plain substring search, it leverages FTS features provided by database systems to improve search results in the following ways:
- Order by relevance
- Search of phrases even when words are ordered differently
- Language-aware search
- Word forms and time-aware search (be/was/is or run/ran)
- Diacritics support
- Morphological search
- Partial search from beginning of the words (e.g. 'Edu*' will return items with word 'Education')
All these advantages can significantly improve the user search experience, helping to find the most relevant content for them.
Database FTS greatly reduces the need in infrastructure overhead requirements for third party FTS solutions like Elasticsearch. However, in some cases it also requires additional configuration of used databases to enable certain search features. Otherwise, only basic FTS features will be available. Currently only a single language per site is supported within full text search.
Language support
Unlike other existing data definition language (DDL) features, full text search is language aware. The language is specified during the creation of the index, and is used by your database in the production of the index. It is used for the likes of breaking words, ignoring noise words (a, it, and etc.), and for other linguistic features provided by the full text search index of your database.
Totara full text search supports one language only. It should be specified in your config.php file, and we recommend setting it to a language compatible with your $CFG→lang. The actual value is database independent.
To set your language add the following to your config.php:
$CFG->dboptions['ftslanguage'] = 'your language';
The actual value is database dependent.
Wildcard search
With FTS, it is possible to search for partial words. To do this, just put an asterisk (*) after the beginning of the word in the search input. For example, searching for 'edu*' will return items that contain the word 'education' in them).
All supported databases work with this feature and no additional configuration is required. If a particular database requires another wildcard character then Totara will handle that for the user.
Accent insensitive search
Generally, having proper vocabularies in database word stemming will provide both accented and unaccented versions of word stem. However, if your database configuration doesn't allow that then accents can be disabled globally by adjusting configuration variable:
$CFG→dboptions['ftsaccentsensitivity'] = false;
And running FTS re-populating tables:
php admin/cli/fts_rebuild_indexes.php
Database-specific information
To get the most out of full text search, database administrators need to follow their database documentation to enable and configure relevant database plugins, install dictionaries, and adjust various database settings.
In addition, we have collected and provided some tips and tricks for the following databases. This is not a replacement for official database documentation, but rather a selection of examples showing how various settings can affect search results.
Next steps
- Full text search in MariaDB
- Full text search in MS SQL Server
- Full text search in MySQL
- Full text search in PostgreSQL