liveBook · Manning

Full-text search dictionary

As explained in Just Use Postgres!

A full-text search dictionary is a PostgreSQL component that converts tokens into lexemes or determines that no lexeme applies.

A full-text search dictionary converts parsed tokens into lexemes or maps them to an empty lexeme when no searchable term applies. Dictionaries can preserve tokens unchanged, stem words, or remove stop words while retaining their positions. section 6.1.1

PostgreSQL selects dictionaries through a full-text search configuration:

  • The simple dictionary leaves values such as 5 unchanged. section 6.1.1
  • The english_stem dictionary stems explorers to {explor} and traveling to {travel}. section 6.1.1
  • Stop words such as are, to, and a become {} while preserving their original positions. section 6.1.1
  • Configurations choose dictionaries by token type; the english configuration uses simple for numbers and english_stem for ordinary words. section 6.1.2

Inspect dictionary decisions

Run SELECT token, description, lexemes, dictionary FROM ts_debug('english', '5 explorers are traveling to a distant galaxy');. The output shows simple producing {5}, english_stem producing {explor}, {travel}, and {galaxi}, and stop words producing {}. section 6.1.2

Listing 6.1 Analyzing tokenization and normalization with ts_debug
SELECT token, description, lexemes, dictionary
FROM ts_debug('5 explorers are traveling to a distant galaxy');

Inspect each token, its type, resulting lexemes, and the dictionary selected during tokenization and normalization. section 6.1.1

How Just Use Postgres! covers it

How deep it goes
Explains stemming, stop-word mapping, position preservation, and configuration-based selection, without covering dictionary creation.
Examples
Demonstrates ts_debug with English and Russian text, showing simple, english_stem, and russian_stem dictionary results.
What you can do after
Diagnose token normalization by querying ts_debug and inspect configuration mappings with the psql \dF+ command.
How it connects
Connects tokenization, normalization, lexemes, full-text search parsers, stemming, stop words, and full-text search configurations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.