CREATE_TEXT_SEARCH_TEMPLATE(7pg18)
๐ CREATE_TEXT_SEARCH_TEMPLATE โ define a new text search template ๐
okay bestie, welcome to the PostgreSQL 18.6 Documentation glow-up of CREATE_TEXT_SEARCH_TEMPLATE(7) โจ this is the one where we build a whole new text search template, and honestly? she's giving backstage-pass energy, because you need superuser to even walk in the door ๐
โจ NAME โจ
CREATE_TEXT_SEARCH_TEMPLATE โ define a new text search template ๐
๐ธ SYNOPSIS ๐ธ
CREATE TEXT SEARCH TEMPLATE name (
[ INIT = init_function , ]
LEXIZE = lexize_function
)
๐ฆ DESCRIPTION ๐ฆ
okay so. CREATE TEXT SEARCH TEMPLATE literally creates a brand new text search template. and what is a template, you ask? a text search template is the thing that defines the functions that implement text search dictionaries. no cap. ๐ฅ
here's the tea though: a template is not useful by itself ๐ญ she's like a dress with no one to wear it. you have to instantiate her as a dictionary to actually use her. and the dictionary is the one that typically specifies the parameters to be given to the template functions. so it's a whole little ecosystem, iykyk ๐ซ
if you give a schema name, the text search template gets created in that specified schema. if you don't? she just gets created in the current schema. default behaviour, no drama ๐
โ ๏ธ NOT ME BEING SERIOUS FOR ONE SECOND: you must be a superuser to use CREATE TEXT SEARCH TEMPLATE. periodt. this restriction exists because an erroneous text search template definition could confuse or even crash the server ๐ so likeโฆ respect the gatekeeping, it's protecting everyone.
and the reason templates are separated from dictionaries in the first place? a template encapsulates the โunsafeโ aspects of defining a dictionary. meanwhile the parameters you can set when defining a dictionary are safe for unprivileged users to set, and so creating a dictionary need not be a privileged operation. it's giving trust boundaries, it's giving responsible architecture ๐
refer to Chapter 12 for further information ๐ (go read it, bestie, it's not optional)
๐ PARAMETERS ๐
nameโ the name of the text search template to be created ๐ท๏ธ she can be schema-qualified, no biggie.init_functionโ the name of the init function for the template โจlexize_functionโ the name of the lexize function for the template โจ
the function names can be schema-qualified if necessary. argument types are not given, since the argument list for each type of function is predetermined โ so don't come for me asking for types, they're already decided ๐
the lexize function is required, but the init function is optional. so one of them is the main character and the other one is a guest star ๐ซถ
and the arguments can appear in any order, not only the one shown above. chaotic order? valid. iconic. ๐
๐ COMPATIBILITY ๐
there is no CREATE TEXT SEARCH TEMPLATE statement in the SQL standard. so yeah, this is a PostgreSQL original ๐
โจ
โญ SEE ALSO โญ
ALTER TEXT SEARCH TEMPLATE(ALTER_TEXT_SEARCH_TEMPLATE(7)) ๐DROP TEXT SEARCH TEMPLATE(DROP_TEXT_SEARCH_TEMPLATE(7)) ๐
and that's the whole page, bestie ๐ฅฐ this one came from the PostgreSQL 18.6 docs and is dated 2026 โ CREATE T... TEMPLATE(7), slay, go make some templates, but likeโฆ responsibly ๐๐ฆ๐
๐ฆ 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