postgresql_16:9.6.48.1 Configuration
PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > unaccent — a text search dictionary which removes diacritics > Configuration
An unaccent dictionary accepts the following options:
RULESis the base name of the file containing the list of translation rules. This file must be stored in$SHAREDIR/tsearch_data/(where$SHAREDIRmeans the PostgreSQL installation's shared-data directory). Its name must end in.rules(which is not to be included in theRULESparameter).
The rules file has the following format:
- Each line represents one translation rule, consisting of a character with accent followed by a character without accent. The first is translated into the second. For example, À A Á A Â A Ã A Ä A Å A Æ AE The two characters must be separated by whitespace, and any leading or trailing whitespace on a line is ignored.
- Alternatively, if only one character is given on a line, instances of that character are deleted; this is useful in languages where accents are represented by separate characters.
- Actually, each “character” can be any string not containing whitespace, so
unaccentdictionaries could be used for other sorts of substring substitutions besides diacritic removal. - As with other PostgreSQL text search configuration files, the rules file must be stored in UTF-8 encoding. The data is automatically translated into the current database's encoding when loaded. Any lines containing untranslatable characters are silently ignored, so that rules files can contain rules that are not applicable in the current encoding.
A more complete example, which is directly useful for most European languages, can be found in unaccent.rules, which is installed in $SHAREDIR/tsearch_data/ when the unaccent module is installed. This rules file translates characters with accents to the same characters without accents, and it also expands ligatures into the equivalent series of simple characters (for example, Æ to AE).