copy_from
The copy_from template derives a new dictionary from an existing one named by FROM, inheriting its template and all of its options, and lets you override just the ones you want to change. This avoids repeating a long definition when you need close variants — for instance copying an English text dictionary and overriding only STEMMING or the stop-word list.
Any option accepted by the source dictionary's template can be given here to override the inherited value; everything you do not mention is carried over unchanged. Because the source's template is inherited too, prefixed options reach into composed sources — STEP2_CASE overrides a pipeline step, TOKENIZER_STOPWORDS overrides a minhash nested analyzer.
Options
| Option | Type | Default | Description |
|---|---|---|---|
FROM | string | required | Name of the source dictionary to copy |
| any option | — | — | Override any option accepted by the source's template; unmentioned options are inherited |
Tokenization
A copy behaves exactly like its source except where you override. Starting from an English text dictionary that lowercases and stems — so running flies indexes as {run,fli} — a copy that overrides only STEMMING = false keeps the inherited locale and lower-casing but emits the full words {running,flies}. The same input through the two dictionaries shows precisely what the override changed and what it left alone.
| Input | Dictionary | Tokens |
|---|---|---|
running flies | source text (CASE = 'lower', STEMMING = true) | {run,fli} |
running flies | copy overriding STEMMING = false | {running,flies} |
Define a stemming English dictionary, then copy it and turn stemming off:
CREATE TEXT SEARCH DICTIONARY english_dict ( template = 'text', locale = 'en_US.UTF-8', case = 'lower', stemming = true);CREATE TEXT SEARCH DICTIONARY english_no_stem ( template = 'copy_from', from = 'english_dict', -- inherit locale and case, override only stemming stemming = false);The source stems each word to its root:
SELECT ts_lexize('english_dict', 'running flies'); ts_lexize----------- {run,fli}The copy inherits locale and case but keeps full words, because only STEMMING was overridden:
SELECT ts_lexize('english_no_stem', 'running flies'); ts_lexize----------------- {running,flies}Examples
Override a pipeline step option
A prefixed option overrides the matching step of a copied pipeline, leaving the other steps intact:
CREATE TEXT SEARCH DICTIONARY pipe_variant ( template = 'copy_from', from = 'pipe_dict', STEP2_CASE = 'upper');Extend a pipeline with additional steps
Naming a step number beyond the source's last step appends a new step to the copied pipeline:
CREATE TEXT SEARCH DICTIONARY pipe_extended ( template = 'copy_from', from = 'pipe_dict', STEP3_TEMPLATE = 'stopwords', STEP3_STOPWORDS = '"bar","foo"');Override a nested minhash analyzer option
A TOKENIZER_-prefixed option reaches into the nested analyzer of a copied minhash dictionary:
CREATE TEXT SEARCH DICTIONARY minhash_variant ( template = 'copy_from', from = 'minhash_text', TOKENIZER_STOPWORDS = '"fox"');See also
pipeline— composed source whose steps can be overriddenminhash— composed source whose nested analyzer can be overridden- CREATE TEXT SEARCH DICTIONARY