{"Entry":{"collection":"fts","key":"dictionary-simple","name":"simple","aliases":[],"metadata":{"aliases":[],"category":"Dictionaries","content_hash":"ba31ffbce53375878bf567124574e6781777ae6e38634f0f255b6173f31a04df","derived_content_hash":"7d25d3f7319dabff96bd88bf36b3000d7f919d9d701761a956a7578c85142274","imported_at":"2026-09-30T00:40:47.632644+08:00","name":"simple","name_zh":"","slug":"dictionary-simple","summary":"simple dictionary: just lower case and check for stopword"}},"Definition":{"Collection":"fts","Key":"dictionary-simple","SourceDatabase":"center","Version":"18","SourceTable":"text_search_component","SourceKey":"dictionary-simple","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":[],"attributes":{"dictionary":"simple","options":"_null_","template":"simple"},"comparison_data":{"dictionary":"simple","options":"_null_","template":"simple"},"comparison_hash":"87ad08852d6fdde36d3b21a277af41a4851190c384c3a92117143fd2804cb2db","description":["simple dictionary: just lower case and check for stopword"],"description_zh":"全文搜索词典 simple。","description_zh_html":"\u003cp\u003e全文搜索词典 simple。\u003c/p\u003e\u003cdl\u003e\u003cdt\u003e模板\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003esimple\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e词典\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003esimple\u003c/code\u003e\u003c/dd\u003e\u003c/dl\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003esimple\u003c/code\u003e 词典模板的工作方式是先把输入词元转换为小写，再根据停用词文件检查它。如果在文件中找到该词元，就返回一个空数组，从而丢弃该词元；否则，返回其小写形式作为正规化后的词位。或者，也可以把该词典配置为把非停用词报告为未识别，从而允许它们传递给列表中的下一个词典。\n   \u003c/p\u003e\u003cp\u003e\n    下面是一个使用 \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e 模板的词典定义示例：\n\n\u003c/p\u003e\u003cp\u003e\n\n    其中，\u003ccode class=\"literal\"\u003eenglish\u003c/code\u003e 是停用词文件的基名。文件完整名称将是 \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/english.stop\u003c/code\u003e，其中 \u003ccode class=\"literal\"\u003e$SHAREDIR\u003c/code\u003e 表示 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 安装的共享数据目录，通常是 \u003ccode class=\"filename\"\u003e/usr/local/share/postgresql\u003c/code\u003e（如果不确定，可用 \u003ccode class=\"command\"\u003epg_config --sharedir\u003c/code\u003e 来确定）。文件格式只是一个单词列表，每行一个单词。空行和行尾空格会被忽略，大写会折叠为小写，但不会对文件内容做其他处理。\n   \u003c/p\u003e\u003cp\u003e\n    现在我们可以测试这个词典：\n\n\u003c/p\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SIMPLE-DICTIONARY\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","facts":[{"label":"Dictionary","value":"simple"},{"label":"Template","value":"simple"},{"label":"Options","value":"_null_"}],"facts_zh":[{"label":"词典","value":"简单"},{"label":"模板","value":"简单"},{"label":"选项","value":"_null_"}],"manual_html":"\u003cdiv class=\"sect2\" id=\"TEXTSEARCH-SIMPLE-DICTIONARY\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e12.6.2. Simple Dictionary \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e dictionary template operates by converting the input token to lower case and checking it against a file of stop words. If it is found in the file then an empty array is returned, causing the token to be discarded. If not, the lower-cased form of the word is returned as the normalized lexeme. Alternatively, the dictionary can be configured to report non-stop-words as unrecognized, allowing them to be passed on to the next dictionary in the list.\u003c/p\u003e\n\u003cp\u003eHere is an example of a dictionary definition using the \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e template:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eCREATE TEXT SEARCH DICTIONARY public.simple_dict (\n    TEMPLATE = pg_catalog.simple,\n    STOPWORDS = english\n);\n\u003c/pre\u003e\n\u003cp\u003eHere, \u003ccode class=\"literal\"\u003eenglish\u003c/code\u003e is the base name of a file of stop words. The file's full name will be \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/english.stop\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, often \u003ccode class=\"filename\"\u003e/usr/local/share/postgresql\u003c/code\u003e (use \u003ccode class=\"command\"\u003epg_config --sharedir\u003c/code\u003e to determine it if you're not sure). The file format is simply a list of words, one per line. Blank lines and trailing spaces are ignored, and upper case is folded to lower case, but no other processing is done on the file contents.\u003c/p\u003e\n\u003cp\u003eNow we can test our dictionary:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003eSELECT ts_lexize('public.simple_dict', 'YeS');\n ts_lexize\n-----------\n {yes}\n\nSELECT ts_lexize('public.simple_dict', 'The');\n ts_lexize\n-----------\n {}\n\u003c/pre\u003e\n\u003cp\u003eWe can also choose to return \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e, instead of the lower-cased word, if it is not found in the stop words file. This behavior is selected by setting the dictionary's \u003ccode class=\"literal\"\u003eAccept\u003c/code\u003e parameter to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. Continuing the example:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003eALTER TEXT SEARCH DICTIONARY public.simple_dict ( Accept = false );\n\nSELECT ts_lexize('public.simple_dict', 'YeS');\n ts_lexize\n-----------\n\n\nSELECT ts_lexize('public.simple_dict', 'The');\n ts_lexize\n-----------\n {}\n\u003c/pre\u003e\n\u003cp\u003eWith the default setting of \u003ccode class=\"literal\"\u003eAccept\u003c/code\u003e = \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, it is only useful to place a \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e dictionary at the end of a list of dictionaries, since it will never pass on any token to a following dictionary. Conversely, \u003ccode class=\"literal\"\u003eAccept\u003c/code\u003e = \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e is only useful when there is at least one following dictionary.\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003eMost types of dictionaries rely on configuration files, such as files of stop words. These files \u003cspan class=\"emphasis\"\u003e\u003cem\u003emust\u003c/em\u003e\u003c/span\u003e be stored in UTF-8 encoding. They will be translated to the actual database encoding, if that is different, when they are read into the server.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003eNormally, a database session will read a dictionary configuration file only once, when it is first used within the session. If you modify a configuration file and want to force existing sessions to pick up the new contents, issue an \u003ccode class=\"command\"\u003eALTER TEXT SEARCH DICTIONARY\u003c/code\u003e command on the dictionary. This can be a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edummy\u003c/span\u003e”\u003c/span\u003e update that doesn't actually change any parameter values.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e","manual_path":"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SIMPLE-DICTIONARY","related":[{"label":"simple template","url":"/wiki/fts/template-simple/?v=18"}],"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-SIMPLE-DICTIONARY"}],"tables":[],"tables_zh":[],"zh_from":{"authored_translation":"source-derived-structured-summary","body_sha256":"0b3a2cab8083aaa87a5e51c1b05176d2cdf82e3f2194cc150a7e38a6fc23ef64","kind":"same-version-chinese-manual-with-source-derived-structured-summary","manual":{"anchor":"TEXTSEARCH-SIMPLE-DICTIONARY","build_id":107,"extraction":"concept-introduction","fragment_sha256":"2e83c9ac05265c9a85199ad776da385802965c03d1d08208f9c3b38c1695d5c2","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-SIMPLE-DICTIONARY","version":"18"},"runtime_rerun":false,"source_facts_revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}},"ManualEvidence":{"manual_path":"/docs/18/textsearch-dictionaries.html#TEXTSEARCH-SIMPLE-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-SIMPLE-DICTIONARY"}]},"MeasuredEvidence":{}},"Text":{"Collection":"fts","Key":"dictionary-simple","SourceDatabase":"center","Version":"18","Locale":"en","Title":"simple","Summary":"simple dictionary: just lower case and check for stopword","BodyHTML":"\u003cdiv id=\"TEXTSEARCH-SIMPLE-DICTIONARY\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e12.6.2. Simple Dictionary \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode\u003esimple\u003c/code\u003e dictionary template operates by converting the input token to lower case and checking it against a file of stop words. If it is found in the file then an empty array is returned, causing the token to be discarded. If not, the lower-cased form of the word is returned as the normalized lexeme. Alternatively, the dictionary can be configured to report non-stop-words as unrecognized, allowing them to be passed on to the next dictionary in the list.\u003c/p\u003e\n\u003cp\u003eHere is an example of a dictionary definition using the \u003ccode\u003esimple\u003c/code\u003e template:\u003c/p\u003e\n\u003cpre\u003eCREATE TEXT SEARCH DICTIONARY public.simple_dict (\n    TEMPLATE = pg_catalog.simple,\n    STOPWORDS = english\n);\n\u003c/pre\u003e\n\u003cp\u003eHere, \u003ccode\u003eenglish\u003c/code\u003e is the base name of a file of stop words. The file\u0026#39;s full name will be \u003ccode\u003e$SHAREDIR/tsearch_data/english.stop\u003c/code\u003e, where \u003ccode\u003e$SHAREDIR\u003c/code\u003e means the \u003cspan\u003ePostgreSQL\u003c/span\u003e installation\u0026#39;s shared-data directory, often \u003ccode\u003e/usr/local/share/postgresql\u003c/code\u003e (use \u003ccode\u003epg_config --sharedir\u003c/code\u003e to determine it if you\u0026#39;re not sure). The file format is simply a list of words, one per line. Blank lines and trailing spaces are ignored, and upper case is folded to lower case, but no other processing is done on the file contents.\u003c/p\u003e\n\u003cp\u003eNow we can test our dictionary:\u003c/p\u003e\n\u003cpre\u003eSELECT ts_lexize(\u0026#39;public.simple_dict\u0026#39;, \u0026#39;YeS\u0026#39;);\n ts_lexize\n-----------\n {yes}\n\nSELECT ts_lexize(\u0026#39;public.simple_dict\u0026#39;, \u0026#39;The\u0026#39;);\n ts_lexize\n-----------\n {}\n\u003c/pre\u003e\n\u003cp\u003eWe can also choose to return \u003ccode\u003eNULL\u003c/code\u003e, instead of the lower-cased word, if it is not found in the stop words file. This behavior is selected by setting the dictionary\u0026#39;s \u003ccode\u003eAccept\u003c/code\u003e parameter to \u003ccode\u003efalse\u003c/code\u003e. Continuing the example:\u003c/p\u003e\n\u003cpre\u003eALTER TEXT SEARCH DICTIONARY public.simple_dict ( Accept = false );\n\nSELECT ts_lexize(\u0026#39;public.simple_dict\u0026#39;, \u0026#39;YeS\u0026#39;);\n ts_lexize\n-----------\n\n\nSELECT ts_lexize(\u0026#39;public.simple_dict\u0026#39;, \u0026#39;The\u0026#39;);\n ts_lexize\n-----------\n {}\n\u003c/pre\u003e\n\u003cp\u003eWith the default setting of \u003ccode\u003eAccept\u003c/code\u003e = \u003ccode\u003etrue\u003c/code\u003e, it is only useful to place a \u003ccode\u003esimple\u003c/code\u003e dictionary at the end of a list of dictionaries, since it will never pass on any token to a following dictionary. Conversely, \u003ccode\u003eAccept\u003c/code\u003e = \u003ccode\u003efalse\u003c/code\u003e is only useful when there is at least one following dictionary.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eCaution\u003c/h3\u003e\n\u003cp\u003eMost types of dictionaries rely on configuration files, such as files of stop words. These files \u003cspan\u003e\u003cem\u003emust\u003c/em\u003e\u003c/span\u003e be stored in UTF-8 encoding. They will be translated to the actual database encoding, if that is different, when they are read into the server.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3\u003eCaution\u003c/h3\u003e\n\u003cp\u003eNormally, a database session will read a dictionary configuration file only once, when it is first used within the session. If you modify a configuration file and want to force existing sessions to pick up the new contents, issue an \u003ccode\u003eALTER TEXT SEARCH DICTIONARY\u003c/code\u003e command on the dictionary. This can be a \u003cspan\u003e“\u003cspan\u003edummy\u003c/span\u003e”\u003c/span\u003e update that doesn\u0026#39;t actually change any parameter values.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"9577b464f5db626c67bc4f144b769e91321e8a29dce4eae0636dbdbf8cb91501","Payload":{"description":["simple dictionary: just lower case and check for stopword"],"manual_html":"\u003cdiv class=\"sect2\" id=\"TEXTSEARCH-SIMPLE-DICTIONARY\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e12.6.2. Simple Dictionary \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e dictionary template operates by converting the input token to lower case and checking it against a file of stop words. If it is found in the file then an empty array is returned, causing the token to be discarded. If not, the lower-cased form of the word is returned as the normalized lexeme. Alternatively, the dictionary can be configured to report non-stop-words as unrecognized, allowing them to be passed on to the next dictionary in the list.\u003c/p\u003e\n\u003cp\u003eHere is an example of a dictionary definition using the \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e template:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eCREATE TEXT SEARCH DICTIONARY public.simple_dict (\n    TEMPLATE = pg_catalog.simple,\n    STOPWORDS = english\n);\n\u003c/pre\u003e\n\u003cp\u003eHere, \u003ccode class=\"literal\"\u003eenglish\u003c/code\u003e is the base name of a file of stop words. The file's full name will be \u003ccode class=\"filename\"\u003e$SHAREDIR/tsearch_data/english.stop\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, often \u003ccode class=\"filename\"\u003e/usr/local/share/postgresql\u003c/code\u003e (use \u003ccode class=\"command\"\u003epg_config --sharedir\u003c/code\u003e to determine it if you're not sure). The file format is simply a list of words, one per line. Blank lines and trailing spaces are ignored, and upper case is folded to lower case, but no other processing is done on the file contents.\u003c/p\u003e\n\u003cp\u003eNow we can test our dictionary:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003eSELECT ts_lexize('public.simple_dict', 'YeS');\n ts_lexize\n-----------\n {yes}\n\nSELECT ts_lexize('public.simple_dict', 'The');\n ts_lexize\n-----------\n {}\n\u003c/pre\u003e\n\u003cp\u003eWe can also choose to return \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e, instead of the lower-cased word, if it is not found in the stop words file. This behavior is selected by setting the dictionary's \u003ccode class=\"literal\"\u003eAccept\u003c/code\u003e parameter to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. Continuing the example:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003eALTER TEXT SEARCH DICTIONARY public.simple_dict ( Accept = false );\n\nSELECT ts_lexize('public.simple_dict', 'YeS');\n ts_lexize\n-----------\n\n\nSELECT ts_lexize('public.simple_dict', 'The');\n ts_lexize\n-----------\n {}\n\u003c/pre\u003e\n\u003cp\u003eWith the default setting of \u003ccode class=\"literal\"\u003eAccept\u003c/code\u003e = \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, it is only useful to place a \u003ccode class=\"literal\"\u003esimple\u003c/code\u003e dictionary at the end of a list of dictionaries, since it will never pass on any token to a following dictionary. Conversely, \u003ccode class=\"literal\"\u003eAccept\u003c/code\u003e = \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e is only useful when there is at least one following dictionary.\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003eMost types of dictionaries rely on configuration files, such as files of stop words. These files \u003cspan class=\"emphasis\"\u003e\u003cem\u003emust\u003c/em\u003e\u003c/span\u003e be stored in UTF-8 encoding. They will be translated to the actual database encoding, if that is different, when they are read into the server.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003eNormally, a database session will read a dictionary configuration file only once, when it is first used within the session. If you modify a configuration file and want to force existing sessions to pick up the new contents, issue an \u003ccode class=\"command\"\u003eALTER TEXT SEARCH DICTIONARY\u003c/code\u003e command on the dictionary. This can be a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edummy\u003c/span\u003e”\u003c/span\u003e update that doesn't actually change any parameter values.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e","related":[{"label":"simple template","url":"/wiki/fts/template-simple/?v=18"}],"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}
