- 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.
推薦閱讀
- Visualforce Development Cookbook(Second Edition)
- Java實用組件集
- Learning Apache Spark 2
- 現(xiàn)代機械運動控制技術
- 會聲會影X4中文版從入門到精通
- Mastering Predictive Analytics with scikit:learn and TensorFlow
- Deep Learning Essentials
- Linux常用命令簡明手冊
- 巧學活用Linux
- Keras Reinforcement Learning Projects
- 傳感器應用技術
- Arduino創(chuàng)意機器人入門:基于ArduBlock(第2版)
- 傳感器原理及應用(第二版)
- 網(wǎng)頁配色萬用寶典
- Deployment with Docker