CREATE_TEXT_SEARCH_TEMPLATE(7pg17)

πŸ“¦ version 17.11, in opensuse-leap 16.0

✨ 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 πŸ‘€


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