ALTER_TEXT_SEARCH_CONFIGURATION(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’– 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 for old_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 FOR form 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 FOR form 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 REPLACE forms substitute new_dictionary for old_dictionary anywhere the latter appears. and here's the nuance: this happens for only the specified token types when FOR appears, or for all mappings of the configuration when it doesn't. so like, FOR is the difference between "just these" and "literally everywhere" ๐Ÿ˜ญ
  • The DROP MAPPING form 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 โ€” unless IF EXISTS appears, 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