# 12.8.测试和调试文本搜索
自定义文本搜索配置的行为很容易令人困惑。本节中描述的功能对于测试文本搜索对象非常有用。您可以测试完整的配置,或者单独测试解析器和字典。
# 12.8.1.配置测试
功能调试
允许轻松测试文本搜索配置。
ts_debug([ config regconfig, ] document text,
OUT alias text,
OUT description text,
OUT token text,
OUT dictionaries regdictionary[],
OUT dictionary regdictionary,
OUT lexemes text[])
returns setof record
调试
显示有关每个标记的信息*文件
由解析器生成并由配置的字典处理。它使用配置
*或默认文本搜索配置
如果省略了这个论点。
调试
为解析器在文本中标识的每个标记返回一行。返回的列是
别名
文本
-令牌类型的短名称描述
文本
-令牌类型的描述代币
文本
-令牌的文本字典
regdictionary[]
-配置为此令牌类型选择的字典词典
regdictionary
-识别标记的字典,或无效的
如果没有词位
文本[]
-识别标记的词典产生的词素,或无效的
如果没有;空数组({}
)意味着它被认为是一个停止词下面是一个简单的例子:
SELECT * FROM ts_debug('english', 'a fat cat sat on a mat - it ate a fat rats');
alias | description | token | dictionaries | dictionary | lexemes
### 12.8.2. Parser Testing
The following functions allow direct testing of a text search parser.
[]()
ts_parse(parser_name text,document text,OUT tokid integer,OUT token text)返回记录集ts_parse(parser_oid,document text,OUT tokid integer,OUT token text)返回记录集
`ts_parse` parses the given *`document`* and returns a series of records, one for each token produced by parsing. Each record includes a `tokid` showing the assigned token type and a `token` which is the text of the token. For example:
从ts_parse中选择*('default','123-一个数字');tokid |令牌
# 12.8.3.字典测试
这个ts_lexize
函数有助于字典测试。
ts_lexize(dict regdictionary, token text) returns text[]
ts_lexize
如果输入*代币
*是字典已知的,或者是空数组(如果字典已知标记但它是停止词),或者无效的
如果是一个未知的词。
例如:
SELECT ts_lexize('english_stem', 'stars');
ts_lexize
### Note
The `ts_lexize` function expects a single *token*, not text. Here is a case where this can be confusing:
选择ts_lexize(‘同义词库’、‘超新星恒星’)为空?柱