分词器测试
函数ts_debug允许简单测试文本搜索分词器。
1. ts_debug([ config regconfig, ] document text,
2. OUT alias text,
3. OUT description text,
4. OUT token text,
5. OUT dictionaries regdictionary[],
6. OUT dictionary regdictionary,
7. OUT lexemes text[])
8. returns setof record
ts_debug显示document的每个token信息,token是由解析器生成,由指定的词典进行处理。如果忽略对应参数,则使用config指定的分词器或者default_text_search_config指定的分词器。
ts_debug为文本解析器标识的每个token返回一行记录。记录中的列分别是:
- alias:text类型,token的别名。
- description:text类型,token的描述。
- token:text类型,token的文本内容。
- dictionaries:regdictionary数组类型,是分词器为token选定的词典。
- dictionary:regdictionary类型,用来识别token的词典。如果为空,则不做识别。
- lexemes:text数组类型,词典识别token时生成的词素。如果为空,则不生成词素。空数组({})意味着token将被识别成停用词。
示例:
1. openGauss=# SELECT * FROM ts_debug('english','a fat cat sat on a mat - it ate a fat rats');
2. alias | description | token | dictionaries | dictionary | lexemes
3. -----------+-----------------+-------+----------------+--------------+---------
4. asciiword | Word, all ASCII | a | {english_stem} | english_stem | {}
5. blank | Space symbols | | {} | |
6. asciiword | Word, all ASCII | fat | {english_stem} | english_stem | {fat}
7. blank | Space symbols | | {} | |
8. asciiword | Word, all ASCII | cat | {english_stem} | english_stem | {cat}
9. blank | Space symbols | | {} | |
10. asciiword | Word, all ASCII | sat | {english_stem} | english_stem | {sat}
11. blank | Space symbols | | {} | |
12. asciiword | Word, all ASCII | on | {english_stem} | english_stem | {}
13. blank | Space symbols | | {} | |
14. asciiword | Word, all ASCII | a | {english_stem} | english_stem | {}
15. blank | Space symbols | | {} | |
16. asciiword | Word, all ASCII | mat | {english_stem} | english_stem | {mat}
17. blank | Space symbols | | {} | |
18. blank | Space symbols | - | {} | |
19. asciiword | Word, all ASCII | it | {english_stem} | english_stem | {}
20. blank | Space symbols | | {} | |
21. asciiword | Word, all ASCII | ate | {english_stem} | english_stem | {ate}
22. blank | Space symbols | | {} | |
23. asciiword | Word, all ASCII | a | {english_stem} | english_stem | {}
24. blank | Space symbols | | {} | |
25. asciiword | Word, all ASCII | fat | {english_stem} | english_stem | {fat}
26. blank | Space symbols | | {} | |
27. asciiword | Word, all ASCII | rats | {english_stem} | english_stem | {rat}
28. (24 rows)
