unaccent
text search dictionary that removes accents
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
unaccent | 1.1 | FUNC | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4990 | unaccent | No | Yes | No | Yes | Yes | No | - |
| Related | pg_trgm fuzzystrmatch citext btree_gist btree_gin prefix dict_xsyn dict_int |
|---|
Version
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.1 | 1.1 | 1.1 | 1.1 | 1.1 |
Install
Note: This is a built-in contrib extension of PostgreSQL
CREATE EXTENSION unaccent;
Usage
Removes accents (diacritic signs) from text. Can be used as a text search dictionary or as a standalone function.
CREATE EXTENSION unaccent;
Functions
| Function | Description |
|---|---|
unaccent(text) | Remove accents using the default dictionary |
unaccent(dictionary regdictionary, text) | Remove accents using a specific dictionary |
Text Search Usage
-- Test the dictionary
SELECT ts_lexize('unaccent', 'Hôtel');
-- {Hotel}
-- Create an accent-insensitive French text search config
CREATE TEXT SEARCH CONFIGURATION fr (COPY = french);
ALTER TEXT SEARCH CONFIGURATION fr
ALTER MAPPING FOR hword, hword_part, word
WITH unaccent, french_stem;
SELECT to_tsvector('fr', 'Hôtels de la Mer');
-- 'hotel':1 'mer':4
-- Accent-insensitive search
SELECT to_tsvector('fr', 'Hôtel de la Mer') @@ to_tsquery('fr', 'Hotels');
-- true
Standalone Function Usage
SELECT unaccent('Hôtel'); -- Hotel
SELECT unaccent('café'); -- cafe
SELECT unaccent('résumé'); -- resume
SELECT unaccent('niño'); -- nino
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.