CREATE_TEXT_SEARCH_TEMPLATE(7pg16)

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

πŸ’… NAME πŸ’…

CREATE_TEXT_SEARCH_TEMPLATE β€” bestie, it literally defines a brand new text search template ✨

So you're reading the PostgreSQL 16.15 Documentation page for this one, and honestly? It's giving "niche but iconic." Let's get into it 🫢


🌸 SYNOPSIS 🌸

CREATE TEXT SEARCH TEMPLATE name (
    [ INIT = init_function , ]
    LEXIZE = lexize_function
)

That's the whole vibe. Look at it. Immaculate πŸŽ€


✨ DESCRIPTION ✨

Okay so CREATE TEXT SEARCH TEMPLATE creates a new text search template. And what even is a template? Text search templates define the functions that implement text search dictionaries. But here's the tea β˜• β€” a template is not useful by itself, like at all. It's not the main character yet. You have to instantiate it as a dictionary to actually use it. And the dictionary typically specifies the parameters you're gonna hand to the template functions. iykyk πŸ’…

If a schema name is given, the text search template gets created in that specified schema. Otherwise? It gets made in the current schema. Simple as that ✨

Now, the serious part β€” ngl, this matters:

You must be a superuser to use CREATE TEXT SEARCH TEMPLATE. This restriction is made because an erroneous text search template definition could confuse or even crash the server πŸ’€πŸ˜­ fr fr.

And the reasoning behind separating templates from dictionaries? Genuinely kinda smart β€” a template encapsulates the "unsafe" aspects of defining a dictionary. The parameters that can be set when defining a dictionary are safe for unprivileged users to set, so creating a dictionary need not be a privileged operation. Slay for the privilege separation honestly πŸ‘‘

Refer to Chapter 12 for further information (yes, that's where the lore lives πŸ“–).


🌈 PARAMETERS 🌈

  • name β€” the name of the text search template to be created. The name can be schema-qualified. πŸ‘‘
  • 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 (no guessing games here πŸŽ€). The lexize function is required, but the init function is optional. So you can't skip LEXIZE, periodt.

Also important, bestie β€” the arguments can appear in any order, not only the one shown above. Freedom of expression βœ¨πŸ¦‹


πŸ¦‹ COMPATIBILITY πŸ¦‹

There is no CREATE TEXT SEARCH TEMPLATE statement in the SQL standard. So... yeah, this is a PostgreSQL-only moment πŸ’… not standard, but we love her anyway πŸ’–


πŸŽ€ SEE ALSO πŸŽ€


And that's the whole page, bestie 🫢 sign-off time: this was PostgreSQL 16.15, dated 2026 β€” go forth and template responsibly, mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from