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

  • Mastering PostgreSQL 9.6
  • Hans Jurgen Schonig
  • 252字
  • 2021-07-09 19:57:23

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.

主站蜘蛛池模板: 大理市| 五台县| 库尔勒市| 广饶县| 阿尔山市| 石泉县| 阿克陶县| 郎溪县| 高唐县| 神农架林区| 台北县| 开封县| 宁武县| 临泉县| 龙门县| 疏附县| 上林县| 万全县| 孝昌县| 图们市| 纳雍县| 丁青县| 彰化县| 姜堰市| 开阳县| 温宿县| 新昌县| 德钦县| 丹东市| 新干县| 禹城市| 札达县| 大埔区| 仙游县| 临漳县| 成安县| 微博| 平原县| 东丽区| 砚山县| 防城港市|