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

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 full-text search 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, and 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 email addresses.

主站蜘蛛池模板: 桦南县| 元阳县| 涞水县| 河西区| 武陟县| 兴和县| 洮南市| 麻阳| 新营市| 卢湾区| 中方县| 株洲市| 板桥市| 库尔勒市| 泰和县| 郁南县| 米易县| 仲巴县| 南川市| 金湖县| 张家口市| 清水县| 左云县| 云安县| 斗六市| 长泰县| 新平| 通道| 五大连池市| 安国市| 左权县| 揭东县| 都江堰市| 五河县| 建昌县| 扎兰屯市| 从化市| 慈利县| 全州县| 平度市| 文登市|