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

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.

主站蜘蛛池模板: 屯昌县| 五台县| 大姚县| 武胜县| 绥棱县| 启东市| 牙克石市| 广昌县| 元谋县| 普格县| 新乡县| 新巴尔虎左旗| 南充市| 安陆市| 隆安县| 兰西县| 田阳县| 沁源县| 柞水县| 宜丰县| 新乡市| 东乡族自治县| 定边县| 贵南县| 绥棱县| 昔阳县| 建水县| 中西区| 广宁县| 宝清县| 莱芜市| 庆安县| 观塘区| 罗田县| 喀什市| 汶川县| 荆门市| 图木舒克市| 阿合奇县| 长白| 虎林市|