unaccent

unaccent

unaccent : text search dictionary that removes accents

Overview

ID Extension Package Version Category License Language
4990
unaccent
unaccent
1.1
FUNC
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-dt-
No
Yes
No
Yes
no
yes
Relationships
See Also
pg_trgm
fuzzystrmatch
citext
btree_gist
btree_gin
prefix
dict_xsyn
dict_int

Packages

PG18 PG17 PG16 PG15 PG14
1.1
1.1
1.1
1.1
1.1

This is a built-in contrib extension ship with the PostgreSQL kernel

Install

Create this extension with:

CREATE EXTENSION unaccent;

Usage

unaccent: text search dictionary for accent removal

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
Last updated on