- 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.
推薦閱讀
- 大數據戰爭:人工智能時代不能不說的事
- Deep Learning Quick Reference
- 反饋系統:多學科視角(原書第2版)
- Hands-On Machine Learning with TensorFlow.js
- CompTIA Network+ Certification Guide
- Windows 7寶典
- PostgreSQL 10 Administration Cookbook
- 工業機器人維護與保養
- 分析力!專業Excel的制作與分析實用法則
- 空間機械臂建模、規劃與控制
- Drupal高手建站技術手冊
- Serverless Design Patterns and Best Practices
- 實戰Windows Azure
- FreeCAD [How-to]
- 計算機辦公應用培訓教程