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

  • Mastering PostgreSQL 10
  • Hans Jürgen Sch?nig
  • 254字
  • 2021-06-30 19:04:00

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.

主站蜘蛛池模板: 上犹县| 桃园县| 工布江达县| 财经| 安远县| 锦屏县| 正定县| 阳新县| 福清市| 瑞金市| 武隆县| 类乌齐县| 锦州市| 汤原县| 星子县| 分宜县| 德州市| 青浦区| 江都市| 泊头市| 惠水县| 武胜县| 仁寿县| 酉阳| 合水县| 扶沟县| 库伦旗| 独山县| 淮南市| 高雄市| 桐柏县| 云林县| 宁阳县| 当雄县| 灌阳县| 绥芬河市| 昌吉市| 临高县| 湖南省| 清河县| 汉川市|