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

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 the parser found, 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, email 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.

主站蜘蛛池模板: 夏津县| 六盘水市| 门源| 中阳县| 新竹县| 兴隆县| 黄龙县| 莱阳市| 盘锦市| 大荔县| 蓬安县| 桦南县| 隆子县| 长泰县| 英德市| 昂仁县| 石林| 孟州市| 嘉义市| 顺平县| 金川县| 尤溪县| 达拉特旗| 宜阳县| 古丈县| 城固县| 安塞县| 乐昌市| 垫江县| 金坛市| 日照市| 镇远县| 西吉县| 长子县| 卓尼县| 包头市| 阿瓦提县| 峨边| 镇安县| 新津县| 梨树县|