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 ]+---------------------------- ...

Get Mastering PostgreSQL 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.