CREATE_TEXT_SEARCH_TEMPLATE(7pg18)

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

๐Ÿ’– 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 โญ


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