官术网_书友最值得收藏!

Debugging your search

Sometimes it is not quite clear why a query matches a given search string. To debug your query, PostgreSQL offers the ts_debug function. From a user's point of view it can be used just like to_tsvector. It reveals a lot about the inner workings of the FTS infrastructure:

test=# \x 
Expanded display is on.
test=# SELECT * FROM ts_debug('english', 'go to www.postgresql-support.de');
-[ RECORD 1 ]+----------------------------
alias | asciiword
description | Word, all ASCII
token | go
dictionaries | {english_stem}
dictionary | english_stem
lexemes | {go}
-[ RECORD 2 ]+----------------------------
alias | blank
description | Space symbols
token |
dictionaries | {}
dictionary |
lexemes |
-[ RECORD 3 ]+----------------------------
alias | asciiword
description | Word, all ASCII
token | to
dictionaries | {english_stem}
dictionary | english_stem
lexemes | {}
-[ RECORD 4 ]+----------------------------
alias | blank
description | Space symbols
token |
dictionaries | {}
dictionary |
lexemes |
-[ RECORD 5 ]+----------------------------
alias | host
description | Host
token | www.postgresql-support.de
dictionaries | {simple}
dictionary | simple
lexemes | {www.postgresql-support.de}

ts_debug will list every token found and display information about the token. You will see which token was found by the parser, the dictionary used, as well as the type of object. In my example, blanks, words, and hosts have been found. You might also see numbers, e-mail addresses, and a lot more. Depending on the type of string, PostgreSQL will handle things differently. For example, it makes absolutely no sense to stem hostnames and e-mail addresses.

主站蜘蛛池模板: 乌审旗| 化德县| 当雄县| 东丰县| 沁源县| 温宿县| 达日县| 贡觉县| 连城县| 乐东| 龙泉市| 石柱| 兴国县| 陕西省| 丹巴县| 霍山县| 门头沟区| 利川市| 家居| 平邑县| 大理市| 乌拉特前旗| 荥经县| 特克斯县| 陆丰市| 巩义市| 营山县| 大荔县| 福海县| 石楼县| 奈曼旗| 塔城市| 呼伦贝尔市| 永川市| 井研县| 元谋县| 宁南县| 芦山县| 遂平县| 青州市| 楚雄市|