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

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.

主站蜘蛛池模板: 定远县| 栖霞市| 梁平县| 吉木萨尔县| 武邑县| 工布江达县| 辛集市| 肇东市| 镶黄旗| 武威市| 长葛市| 门头沟区| 敖汉旗| 万山特区| 子洲县| 渝中区| 汤阴县| 翁牛特旗| 嘉禾县| 宣化县| 荔波县| 沙湾县| 蕲春县| 边坝县| 杭州市| 樟树市| 彭阳县| 安福县| 大丰市| 开阳县| 酉阳| 微博| 鞍山市| 通州市| 嘉定区| 章丘市| 三门峡市| 紫金县| 新田县| 梁山县| 东源县|