CREATE_TEXT_SEARCH_TEMPLATE(7pg17)
β¨ CREATE_TEXT_SEARCH_TEMPLATE π
okay bestie, gather round, because today we're talking about CREATE TEXT SEARCH TEMPLATE in the PostgreSQL 17.11 docs π«Ά this one's a little niche but it's lowkey iconic once you get it, i promise.
πΈ NAME πΈ
CREATE_TEXT_SEARCH_TEMPLATE β define a brand new text search template, no cap β¨
π SYNOPSIS π
CREATE TEXT SEARCH TEMPLATE name (
[ INIT = init_function , ]
LEXIZE = lexize_function
)
π¦ DESCRIPTION π¦
so CREATE TEXT SEARCH TEMPLATE literally creates a new text search template. and what even is a template? it's the thing that defines the functions that implement text search dictionaries π
like, it's the blueprint, the main character energy behind the scenes.
here's the tea though: a template is not useful by itself. you have to instantiate it as a dictionary before it actually does anything. the dictionary is what typically specifies the parameters that get handed to the template functions. think of the template as the vibe and the dictionary as the actual outfit, y'know? π
if you give a schema name, the text search template gets created in that schema. if you don't? it lands in the current schema, default behavior, it's giving "wherever i happen to be standing" π
β οΈ important vibe check: you MUST be a superuser to use CREATE TEXT SEARCH TEMPLATE. and there's a real reason for that, not just gatekeeping β a wrong text search template definition could confuse the server or even crash it π fr fr, that's the actual wording. dangerous.
the reason templates and dictionaries are separate things at all is that 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, so creating a dictionary doesn't need to be a privileged operation at all. slay for accessibility honestly π
refer to Chapter 12 for further information, bestie, that's where the deep lore lives π
β PARAMETERS β
nameβ the name of the text search template you're creating. it can be schema-qualified, so go off with that<italic>schema</italic>.<italic>name</italic>energy πinit_functionβ the name of the init function for the template β¨lexize_functionβ the name of the lexize function for the template π
okay so a couple things about these function names: they can be schema-qualified if necessary, and you do not give argument types β because the argument list for each type of function is predetermined, so it's already decided for you, iykyk π¦
also, the lexize function is required, but the init function is optional. and the arguments can show up in any order, not just the order shown above β so you do you, bestie, the parser doesn't care π
π COMPATIBILITY π
there is no CREATE TEXT SEARCH TEMPLATE statement in the SQL standard. not a thing. we invented this one ourselves π periodt.
π 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 πΈ mwah π this was PostgreSQL 17.11, dated 2026 β go forth and template responsibly, and remember: superuser only, don't crash the server, ilysm π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms