June 2024
Intermediate to advanced
456 pages
11h 34m
English
PostgreSQL supports accented characters in document text and search queries using the unaccent extension. You enabled this extension earlier. Let’s try out the TS_LEXIZE() function from the extension.
Run the following query from psql, passing in Esmé, which has an accent on the second “e”:
| | SELECT TS_LEXIZE('unaccent','Esmé'); |
| | -- ts_lexize |
| | -- ----------- |
| | -- {Esme} |
This function removes the accent. Results from this function can be turned into a tsvector. This example creates a tsvector after removing accents, and then the tsvector is searched with input text. The @@ operator is used, which returns a Boolean value when text matches.
Read now
Unlock full access