ALTER_TEXT_SEARCH_CONFIGURATION(7pg18)
๐ ALTER TEXT SEARCH CONFIGURATION ๐
okay bestie, we're doing the ALTER TEXT SEARCH CONFIGURATION page from the PostgreSQL 18.6 Documentation and honestly? it's giving glow-up era for your text search setups โจ
๐ธ NAME ๐ธ
ALTER_TEXT_SEARCH_CONFIGURATION โ bestie, this is the one that changes the definition of a text search configuration ๐
๐ SYNOPSIS ๐
ALTER TEXT SEARCH CONFIGURATION name
ADD MAPPING FOR token_type [, ... ] WITH dictionary_name [, ... ]
ALTER TEXT SEARCH CONFIGURATION name
ALTER MAPPING FOR token_type [, ... ] WITH dictionary_name [, ... ]
ALTER TEXT SEARCH CONFIGURATION name
ALTER MAPPING REPLACE old_dictionary WITH new_dictionary
ALTER TEXT SEARCH CONFIGURATION name
ALTER MAPPING FOR token_type [, ... ] REPLACE old_dictionary WITH new_dictionary
ALTER TEXT SEARCH CONFIGURATION name
DROP MAPPING [ IF EXISTS ] FOR token_type [, ... ]
ALTER TEXT SEARCH CONFIGURATION name RENAME TO new_name
ALTER TEXT SEARCH CONFIGURATION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER TEXT SEARCH CONFIGURATION name SET SCHEMA new_schema
no cap, that's a whole lot of syntax and every single line of it is valid ๐ซถ
โจ DESCRIPTION โจ
so like, ALTER TEXT SEARCH CONFIGURATION changes the definition of a text search configuration. you can remix its mappings from token types to dictionaries, or you can change the configuration's name or owner. main character energy, honestly ๐
๐จ okay important one: you must be the owner of the configuration to use ALTER TEXT SEARCH CONFIGURATION. not your friend, not your group chat, you. periodt.
๐ฆ PARAMETERS ๐ฆ
nameโ the name of an existing text search configuration. optionally schema-qualified, so you can be all specific about it ๐token_typeโ the name of a token type that gets emitted by the configuration's parser ๐dictionary_nameโ the name of a text search dictionary to be consulted for the specified token type(s). and ooh, if you list multiple dictionaries, they get consulted in the specified order. order matters bestie, it's giving queue behavior ๐old_dictionaryโ the name of a text search dictionary that's getting replaced in the mapping. rip to them ๐new_dictionaryโ the name of a text search dictionary to be substituted forold_dictionary. glow up ๐ซnew_nameโ the new name of the text search configuration โจnew_ownerโ the new owner of the text search configuration ๐new_schemaโ the new schema for the text search configuration ๐๏ธ
๐ so what do all the forms actually DO ๐
let me break it down because this is the part everyone skips and then gets confused, and not me being that friend, i would never ๐
- The
ADD MAPPING FORform installs a list of dictionaries to be consulted for the specified token type(s). and heads up โ it is an error if there's already a mapping for any of those token types. it's giving "no double booking" ๐ซ - The
ALTER MAPPING FORform does the same thing, but it first removes any existing mapping for those token types. so it's the chill, non-conflict version ๐ง - The
ALTER MAPPING REPLACEforms substitutenew_dictionaryforold_dictionaryanywhere the latter appears. and here's the nuance: this happens for only the specified token types whenFORappears, or for all mappings of the configuration when it doesn't. so like,FORis the difference between "just these" and "literally everywhere" ๐ญ - The
DROP MAPPINGform removes all dictionaries for the specified token type(s), which causes tokens of those types to be ignored by the text search configuration. bye felicia ๐ and it is an error if there's no mapping for those token types โ unlessIF EXISTSappears, in which case you're safe ๐
๐ซ EXAMPLES ๐ซ
okay so this example replaces the english dictionary with the swedish dictionary anywhere that english is used within my_config. iconic behavior honestly:
ALTER TEXT SEARCH CONFIGURATION my_config
ALTER MAPPING REPLACE english WITH swedish;
๐ COMPATIBILITY ๐
ngl, there is no ALTER TEXT SEARCH CONFIGURATION statement in the SQL standard. it's a PostgreSQL original bestie, we made this ๐
๐ซถ SEE ALSO ๐ซถ
CREATE TEXT SEARCH CONFIGURATION(CREATE_TEXT_SEARCH_CONFIGURATION(7))DROP TEXT SEARCH CONFIGURATION(DROP_TEXT_SEARCH_CONFIGURATION(7))
and that's the whole page bestie!! ๐ this was PostgreSQL 18.6, dated 2026, and it's the ALTER TEXT SEARCH CONFIGURATION(7) page โ go forth and remap your token types, you absolute legend ๐๐โจ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms