{"Entry":{"collection":"fts","key":"template-synonym","name":"synonym","aliases":[],"metadata":{"aliases":[],"category":"Dictionary templates","content_hash":"2ba0f874efe2b090ddafcead78d935171d50f41a68f43ec3f547ce6709755d8c","derived_content_hash":"1c57ff0ab2f1f532e27587c2e030e4a718d3439e8dbd2b378a1480752fcd23a6","imported_at":"2026-09-30T00:40:47.669135+08:00","name":"synonym","name_zh":"","slug":"template-synonym","summary":"synonym dictionary: replace word by its synonym"}},"Definition":{"Collection":"fts","Key":"template-synonym","SourceDatabase":"center","Version":"18","SourceTable":"text_search_component","SourceKey":"template-synonym","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":[],"attributes":{"tmplinit":"dsynonym_init","tmpllexize":"dsynonym_lexize","tmplname":"synonym"},"comparison_data":{"tmplinit":"dsynonym_init","tmpllexize":"dsynonym_lexize","tmplname":"synonym"},"comparison_hash":"01c20906081775fc96faef281e0dd79723c3780554b4aa04d12402789f7a198e","description":["synonym dictionary: replace word by its synonym"],"description_zh":"全文搜索模板 synonym。","description_zh_html":"\u003cp\u003e全文搜索模板 synonym。\u003c/p\u003e\u003cdl\u003e\u003c/dl\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cp\u003e\n    这个词典模板用于创建把一个单词替换为同义词的词典。不支持短语（对此请使用分类词典模板\u003ca class=\"xref\" href=\"/zh/docs/18/textsearch-dictionaries.html#TEXTSEARCH-THESAURUS\"\u003e第 12.6.4 节\u003c/a\u003e）。同义词词典可以用来克服语言学上的问题，例如防止英语词干分析词典把\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eParis\u003c/span\u003e”\u003c/span\u003e约简成\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003epari\u003c/span\u003e”\u003c/span\u003e。只要在同义词词典中加入一行 \u003ccode class=\"literal\"\u003eParis paris\u003c/code\u003e，并把该词典放在 \u003ccode class=\"literal\"\u003eenglish_stem\u003c/code\u003e 词典之前即可。例如：\n\n\u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003esynonym\u003c/code\u003e 模板要求的唯一参数是 \u003ccode class=\"literal\"\u003eSYNONYMS\u003c/code\u003e，它是其配置文件的基名 — 上例中的 \u003ccode class=\"literal\"\u003emy_synonyms\u003c/code\u003e。该文件的完整名称将是 \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/my_synonyms.syn\u003c/code\u003e（其中 \u003ccode class=\"literal\"\u003e$SHAREDIR\u003c/code\u003e 表示 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 安装的共享数据目录）。该文件格式是每行一个要被替换的词，后面跟着它的同义词，用空白分隔。空行和结尾的空格会被忽略。\n   \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003esynonym\u003c/code\u003e 模板还有一个可选参数 \u003ccode class=\"literal\"\u003eCaseSensitive\u003c/code\u003e，默认值为 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。当 \u003ccode class=\"literal\"\u003eCaseSensitive\u003c/code\u003e 为 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e 时，同义词文件中的词会像输入词元一样折叠为小写。当它为 \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e 时，词和词元都不会被折叠为小写，而是按原样比较。\n   \u003c/p\u003e\u003cp\u003e\n    可以在配置文件中把星号（\u003ccode class=\"literal\"\u003e*\u003c/code\u003e）放在同义词末尾，表示该同义词是一个前缀。当该条目用于 \u003ccode class=\"function\"\u003eto_tsvector()\u003c/code\u003e 时，星号会被忽略；但当它用于 \u003ccode class=\"function\"\u003eto_tsquery()\u003c/code\u003e 时，结果将是一个带有前缀匹配标记的查询项（见\u003ca class=\"xref\" href=\"/zh/docs/18/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES\"\u003e第 12.3.2 节\u003c/a\u003e）。例如，假设在 \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/synonym_sample.syn\u003c/code\u003e 中有以下条目：\n\u003c/p\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SYNONYM-DICTIONARY\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","facts":[{"label":"Tmplname","value":"synonym"},{"label":"Tmplinit","value":"dsynonym_init"},{"label":"Tmpllexize","value":"dsynonym_lexize"}],"facts_zh":[{"label":"模板名称（tmplname）","value":"synonym"},{"label":"初始化函数（tmplinit）","value":"dsynonym_init"},{"label":"词法化函数（tmpllexize）","value":"dsynonym_lexize"}],"manual_html":"\u003cdiv class=\"sect2\" id=\"TEXTSEARCH-SYNONYM-DICTIONARY\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e12.6.3. Synonym Dictionary \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThis dictionary template is used to create dictionaries that replace a word with a synonym. Phrases are not supported (use the thesaurus template (\u003ca class=\"xref\" href=\"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-THESAURUS\" title=\"12.6.4. Thesaurus Dictionary\"\u003eSection 12.6.4\u003c/a\u003e) for that). A synonym dictionary can be used to overcome linguistic problems, for example, to prevent an English stemmer dictionary from reducing the word \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eParis\u003c/span\u003e”\u003c/span\u003e to \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003epari\u003c/span\u003e”\u003c/span\u003e. It is enough to have a \u003ccode class=\"literal\"\u003eParis paris\u003c/code\u003e line in the synonym dictionary and put it before the \u003ccode class=\"literal\"\u003eenglish_stem\u003c/code\u003e dictionary. For example:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003eSELECT * FROM ts_debug('english', 'Paris');\n   alias   |   description   | token |  dictionaries  |  dictionary  | lexemes\n-----------+-----------------+-------+----------------+--------------+---------\n asciiword | Word, all ASCII | Paris | {english_stem} | english_stem | {pari}\n\nCREATE TEXT SEARCH DICTIONARY my_synonym (\n    TEMPLATE = synonym,\n    SYNONYMS = my_synonyms\n);\n\nALTER TEXT SEARCH CONFIGURATION english\n    ALTER MAPPING FOR asciiword\n    WITH my_synonym, english_stem;\n\nSELECT * FROM ts_debug('english', 'Paris');\n   alias   |   description   | token |       dictionaries        | dictionary | lexemes\n-----------+-----------------+-------+---------------------------+------------+---------\n asciiword | Word, all ASCII | Paris | {my_synonym,english_stem} | my_synonym | {paris}\n\u003c/pre\u003e\n\u003cp\u003eThe only parameter required by the \u003ccode class=\"literal\"\u003esynonym\u003c/code\u003e template is \u003ccode class=\"literal\"\u003eSYNONYMS\u003c/code\u003e, which is the base name of its configuration file — \u003ccode class=\"literal\"\u003emy_synonyms\u003c/code\u003e in the above example. The file's full name will be \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/my_synonyms.syn\u003c/code\u003e (where \u003ccode class=\"literal\"\u003e$SHAREDIR\u003c/code\u003e means the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e installation's shared-data directory). The file format is just one line per word to be substituted, with the word followed by its synonym, separated by white space. Blank lines and trailing spaces are ignored.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003esynonym\u003c/code\u003e template also has an optional parameter \u003ccode class=\"literal\"\u003eCaseSensitive\u003c/code\u003e, which defaults to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. When \u003ccode class=\"literal\"\u003eCaseSensitive\u003c/code\u003e is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, words in the synonym file are folded to lower case, as are input tokens. When it is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, words and tokens are not folded to lower case, but are compared as-is.\u003c/p\u003e\n\u003cp\u003eAn asterisk (\u003ccode class=\"literal\"\u003e*\u003c/code\u003e) can be placed at the end of a synonym in the configuration file. This indicates that the synonym is a prefix. The asterisk is ignored when the entry is used in \u003ccode class=\"function\"\u003eto_tsvector()\u003c/code\u003e, but when it is used in \u003ccode class=\"function\"\u003eto_tsquery()\u003c/code\u003e, the result will be a query item with the prefix match marker (see \u003ca class=\"xref\" href=\"/docs/18/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES\" title=\"12.3.2. Parsing Queries\"\u003eSection 12.3.2\u003c/a\u003e). For example, suppose we have these entries in \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/synonym_sample.syn\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epostgres        pgsql\npostgresql      pgsql\npostgre pgsql\ngogle   googl\nindices index*\n\u003c/pre\u003e\n\u003cp\u003eThen we will get these results:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003emydb=# CREATE TEXT SEARCH DICTIONARY syn (template=synonym, synonyms='synonym_sample');\nmydb=# SELECT ts_lexize('syn', 'indices');\n ts_lexize\n-----------\n {index}\n(1 row)\n\nmydb=# CREATE TEXT SEARCH CONFIGURATION tst (copy=simple);\nmydb=# ALTER TEXT SEARCH CONFIGURATION tst ALTER MAPPING FOR asciiword WITH syn;\nmydb=# SELECT to_tsvector('tst', 'indices');\n to_tsvector\n-------------\n 'index':1\n(1 row)\n\nmydb=# SELECT to_tsquery('tst', 'indices');\n to_tsquery\n------------\n 'index':*\n(1 row)\n\nmydb=# SELECT 'indexes are very useful'::tsvector;\n            tsvector\n---------------------------------\n 'are' 'indexes' 'useful' 'very'\n(1 row)\n\nmydb=# SELECT 'indexes are very useful'::tsvector @@ to_tsquery('tst', 'indices');\n ?column?\n----------\n t\n(1 row)\n\u003c/pre\u003e\n\u003c/div\u003e","manual_path":"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SYNONYM-DICTIONARY","related":[],"release":{"catalog_fingerprint":"65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502","channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"sections_zh":[],"signature":"","sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual","path":"textsearch-dictionaries.html","sha256":"736b212545d12542777fa6d106bbf5b159fe5617123a208d36a8a572130c3fa6","url":"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SYNONYM-DICTIONARY"}],"tables":[],"tables_zh":[],"zh_from":{"authored_translation":"source-derived-structured-summary","body_sha256":"e3d31f00a4f0662e9452be0cfddb7c75fb41cc6698d30b3a8ffc7d3ee0266b9e","kind":"same-version-chinese-manual-with-source-derived-structured-summary","manual":{"anchor":"TEXTSEARCH-SYNONYM-DICTIONARY","build_id":107,"extraction":"concept-introduction","fragment_sha256":"cc51c786f1776dd53256508c953d456004bec45ca4a0e6e82592120eb8a39955","locale":"zh-Hans","page_key":"textsearch-dictionaries.html","source_hash":"ad37f192124c8008d43fdfc38b16025993b2cc0dd6d9e451d283db5fcf2b0ba1","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SYNONYM-DICTIONARY","version":"18"},"runtime_rerun":false,"source_facts_revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}},"ManualEvidence":{"manual_path":"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SYNONYM-DICTIONARY","release":{"catalog_fingerprint":"65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502","channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual","path":"textsearch-dictionaries.html","sha256":"736b212545d12542777fa6d106bbf5b159fe5617123a208d36a8a572130c3fa6","url":"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SYNONYM-DICTIONARY"}]},"MeasuredEvidence":{}},"Text":{"Collection":"fts","Key":"template-synonym","SourceDatabase":"center","Version":"18","Locale":"en","Title":"synonym","Summary":"synonym dictionary: replace word by its synonym","BodyHTML":"\u003cdiv id=\"TEXTSEARCH-SYNONYM-DICTIONARY\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e12.6.3. Synonym Dictionary \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThis dictionary template is used to create dictionaries that replace a word with a synonym. Phrases are not supported (use the thesaurus template (\u003ca href=\"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-THESAURUS\" rel=\"nofollow\"\u003eSection 12.6.4\u003c/a\u003e) for that). A synonym dictionary can be used to overcome linguistic problems, for example, to prevent an English stemmer dictionary from reducing the word \u003cspan\u003e“\u003cspan\u003eParis\u003c/span\u003e”\u003c/span\u003e to \u003cspan\u003e“\u003cspan\u003epari\u003c/span\u003e”\u003c/span\u003e. It is enough to have a \u003ccode\u003eParis paris\u003c/code\u003e line in the synonym dictionary and put it before the \u003ccode\u003eenglish_stem\u003c/code\u003e dictionary. For example:\u003c/p\u003e\n\u003cpre\u003eSELECT * FROM ts_debug(\u0026#39;english\u0026#39;, \u0026#39;Paris\u0026#39;);\n   alias   |   description   | token |  dictionaries  |  dictionary  | lexemes\n-----------+-----------------+-------+----------------+--------------+---------\n asciiword | Word, all ASCII | Paris | {english_stem} | english_stem | {pari}\n\nCREATE TEXT SEARCH DICTIONARY my_synonym (\n    TEMPLATE = synonym,\n    SYNONYMS = my_synonyms\n);\n\nALTER TEXT SEARCH CONFIGURATION english\n    ALTER MAPPING FOR asciiword\n    WITH my_synonym, english_stem;\n\nSELECT * FROM ts_debug(\u0026#39;english\u0026#39;, \u0026#39;Paris\u0026#39;);\n   alias   |   description   | token |       dictionaries        | dictionary | lexemes\n-----------+-----------------+-------+---------------------------+------------+---------\n asciiword | Word, all ASCII | Paris | {my_synonym,english_stem} | my_synonym | {paris}\n\u003c/pre\u003e\n\u003cp\u003eThe only parameter required by the \u003ccode\u003esynonym\u003c/code\u003e template is \u003ccode\u003eSYNONYMS\u003c/code\u003e, which is the base name of its configuration file — \u003ccode\u003emy_synonyms\u003c/code\u003e in the above example. The file\u0026#39;s full name will be \u003ccode\u003e$SHAREDIR/tsearch_data/my_synonyms.syn\u003c/code\u003e (where \u003ccode\u003e$SHAREDIR\u003c/code\u003e means the \u003cspan\u003ePostgreSQL\u003c/span\u003e installation\u0026#39;s shared-data directory). The file format is just one line per word to be substituted, with the word followed by its synonym, separated by white space. Blank lines and trailing spaces are ignored.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003esynonym\u003c/code\u003e template also has an optional parameter \u003ccode\u003eCaseSensitive\u003c/code\u003e, which defaults to \u003ccode\u003efalse\u003c/code\u003e. When \u003ccode\u003eCaseSensitive\u003c/code\u003e is \u003ccode\u003efalse\u003c/code\u003e, words in the synonym file are folded to lower case, as are input tokens. When it is \u003ccode\u003etrue\u003c/code\u003e, words and tokens are not folded to lower case, but are compared as-is.\u003c/p\u003e\n\u003cp\u003eAn asterisk (\u003ccode\u003e*\u003c/code\u003e) can be placed at the end of a synonym in the configuration file. This indicates that the synonym is a prefix. The asterisk is ignored when the entry is used in \u003ccode\u003eto_tsvector()\u003c/code\u003e, but when it is used in \u003ccode\u003eto_tsquery()\u003c/code\u003e, the result will be a query item with the prefix match marker (see \u003ca href=\"/docs/18/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES\" rel=\"nofollow\"\u003eSection 12.3.2\u003c/a\u003e). For example, suppose we have these entries in \u003ccode\u003e$SHAREDIR/tsearch_data/synonym_sample.syn\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003epostgres        pgsql\npostgresql      pgsql\npostgre pgsql\ngogle   googl\nindices index*\n\u003c/pre\u003e\n\u003cp\u003eThen we will get these results:\u003c/p\u003e\n\u003cpre\u003emydb=# CREATE TEXT SEARCH DICTIONARY syn (template=synonym, synonyms=\u0026#39;synonym_sample\u0026#39;);\nmydb=# SELECT ts_lexize(\u0026#39;syn\u0026#39;, \u0026#39;indices\u0026#39;);\n ts_lexize\n-----------\n {index}\n(1 row)\n\nmydb=# CREATE TEXT SEARCH CONFIGURATION tst (copy=simple);\nmydb=# ALTER TEXT SEARCH CONFIGURATION tst ALTER MAPPING FOR asciiword WITH syn;\nmydb=# SELECT to_tsvector(\u0026#39;tst\u0026#39;, \u0026#39;indices\u0026#39;);\n to_tsvector\n-------------\n \u0026#39;index\u0026#39;:1\n(1 row)\n\nmydb=# SELECT to_tsquery(\u0026#39;tst\u0026#39;, \u0026#39;indices\u0026#39;);\n to_tsquery\n------------\n \u0026#39;index\u0026#39;:*\n(1 row)\n\nmydb=# SELECT \u0026#39;indexes are very useful\u0026#39;::tsvector;\n            tsvector\n---------------------------------\n \u0026#39;are\u0026#39; \u0026#39;indexes\u0026#39; \u0026#39;useful\u0026#39; \u0026#39;very\u0026#39;\n(1 row)\n\nmydb=# SELECT \u0026#39;indexes are very useful\u0026#39;::tsvector @@ to_tsquery(\u0026#39;tst\u0026#39;, \u0026#39;indices\u0026#39;);\n ?column?\n----------\n t\n(1 row)\n\u003c/pre\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"0f04f67f22c56d37a5988536f723786fc072374aad204bbcb8ada9bcd9a838a4","Payload":{"description":["synonym dictionary: replace word by its synonym"],"manual_html":"\u003cdiv class=\"sect2\" id=\"TEXTSEARCH-SYNONYM-DICTIONARY\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e12.6.3. Synonym Dictionary \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThis dictionary template is used to create dictionaries that replace a word with a synonym. Phrases are not supported (use the thesaurus template (\u003ca class=\"xref\" href=\"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-THESAURUS\" title=\"12.6.4. Thesaurus Dictionary\"\u003eSection 12.6.4\u003c/a\u003e) for that). A synonym dictionary can be used to overcome linguistic problems, for example, to prevent an English stemmer dictionary from reducing the word \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eParis\u003c/span\u003e”\u003c/span\u003e to \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003epari\u003c/span\u003e”\u003c/span\u003e. It is enough to have a \u003ccode class=\"literal\"\u003eParis paris\u003c/code\u003e line in the synonym dictionary and put it before the \u003ccode class=\"literal\"\u003eenglish_stem\u003c/code\u003e dictionary. For example:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003eSELECT * FROM ts_debug('english', 'Paris');\n   alias   |   description   | token |  dictionaries  |  dictionary  | lexemes\n-----------+-----------------+-------+----------------+--------------+---------\n asciiword | Word, all ASCII | Paris | {english_stem} | english_stem | {pari}\n\nCREATE TEXT SEARCH DICTIONARY my_synonym (\n    TEMPLATE = synonym,\n    SYNONYMS = my_synonyms\n);\n\nALTER TEXT SEARCH CONFIGURATION english\n    ALTER MAPPING FOR asciiword\n    WITH my_synonym, english_stem;\n\nSELECT * FROM ts_debug('english', 'Paris');\n   alias   |   description   | token |       dictionaries        | dictionary | lexemes\n-----------+-----------------+-------+---------------------------+------------+---------\n asciiword | Word, all ASCII | Paris | {my_synonym,english_stem} | my_synonym | {paris}\n\u003c/pre\u003e\n\u003cp\u003eThe only parameter required by the \u003ccode class=\"literal\"\u003esynonym\u003c/code\u003e template is \u003ccode class=\"literal\"\u003eSYNONYMS\u003c/code\u003e, which is the base name of its configuration file — \u003ccode class=\"literal\"\u003emy_synonyms\u003c/code\u003e in the above example. The file's full name will be \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/my_synonyms.syn\u003c/code\u003e (where \u003ccode class=\"literal\"\u003e$SHAREDIR\u003c/code\u003e means the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e installation's shared-data directory). The file format is just one line per word to be substituted, with the word followed by its synonym, separated by white space. Blank lines and trailing spaces are ignored.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003esynonym\u003c/code\u003e template also has an optional parameter \u003ccode class=\"literal\"\u003eCaseSensitive\u003c/code\u003e, which defaults to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. When \u003ccode class=\"literal\"\u003eCaseSensitive\u003c/code\u003e is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, words in the synonym file are folded to lower case, as are input tokens. When it is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, words and tokens are not folded to lower case, but are compared as-is.\u003c/p\u003e\n\u003cp\u003eAn asterisk (\u003ccode class=\"literal\"\u003e*\u003c/code\u003e) can be placed at the end of a synonym in the configuration file. This indicates that the synonym is a prefix. The asterisk is ignored when the entry is used in \u003ccode class=\"function\"\u003eto_tsvector()\u003c/code\u003e, but when it is used in \u003ccode class=\"function\"\u003eto_tsquery()\u003c/code\u003e, the result will be a query item with the prefix match marker (see \u003ca class=\"xref\" href=\"/docs/18/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES\" title=\"12.3.2. Parsing Queries\"\u003eSection 12.3.2\u003c/a\u003e). For example, suppose we have these entries in \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/synonym_sample.syn\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epostgres        pgsql\npostgresql      pgsql\npostgre pgsql\ngogle   googl\nindices index*\n\u003c/pre\u003e\n\u003cp\u003eThen we will get these results:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003emydb=# CREATE TEXT SEARCH DICTIONARY syn (template=synonym, synonyms='synonym_sample');\nmydb=# SELECT ts_lexize('syn', 'indices');\n ts_lexize\n-----------\n {index}\n(1 row)\n\nmydb=# CREATE TEXT SEARCH CONFIGURATION tst (copy=simple);\nmydb=# ALTER TEXT SEARCH CONFIGURATION tst ALTER MAPPING FOR asciiword WITH syn;\nmydb=# SELECT to_tsvector('tst', 'indices');\n to_tsvector\n-------------\n 'index':1\n(1 row)\n\nmydb=# SELECT to_tsquery('tst', 'indices');\n to_tsquery\n------------\n 'index':*\n(1 row)\n\nmydb=# SELECT 'indexes are very useful'::tsvector;\n            tsvector\n---------------------------------\n 'are' 'indexes' 'useful' 'very'\n(1 row)\n\nmydb=# SELECT 'indexes are very useful'::tsvector @@ to_tsquery('tst', 'indices');\n ?column?\n----------\n t\n(1 row)\n\u003c/pre\u003e\n\u003c/div\u003e","related":[],"sections":[],"tables":[]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
