A text search configuration specifies all options necessary to transform a document into a : the parser to use to break text into tokens, and the dictionaries to use to transform each token into a lexeme. Every call of to_tsvector or to_tsquery needs a text search configuration to perform its processing. The configuration parameter specifies the name of the default configuration, which is the one used by text search functions if an explicit configuration parameter is omitted. It can be set in postgresql.conf using the gpconfig command-line utility, or set for an individual session using the SET command.

    Several predefined text search configurations are available, and you can create custom configurations easily. To facilitate management of text search objects, a set of SQL commands is available, and there are several psql commands that display information about text search objects (psql Support).

    As an example we will create a configuration pg, starting by duplicating the built-in english configuration:

    1. pgsql pg
    2. postgresql pg

    We define the synonym dictionary like this:

    Next we register the Ispell dictionary , which has its own configuration files:

    1. CREATE TEXT SEARCH DICTIONARY english_ispell (
    2. TEMPLATE = ispell,
    3. DictFile = english,
    4. AffFile = english,
    5. StopWords = english

    Now we can set up the mappings for words in configuration pg:

    1. ALTER TEXT SEARCH CONFIGURATION pg
    2. DROP MAPPING FOR email, url, url_path, sfloat, float;

    Now we can test our configuration:

    The next step is to set the session to use the new configuration, which was created in the public schema:

    1. => \dF
    2. Schema | Name | Description
    3. ---------+------+-------------
    4. public | pg |
    5. SET default_text_search_config = 'public.pg';
    6. SET
    7. SHOW default_text_search_config;
    8. default_text_search_config
    9. ----------------------------
    10. public.pg

    Parent topic: