How can I make fulltext search accent insensitive?

I would like to have the same search result when I type either 'Hôtel' or 'Hotel'.

2 votes

2 answers

2401 views

ANSWER



This can be achieved easily if you are using PostgreSQL 9.0 and above through the unaccent contribution (http://www.postgresql.org/docs/9.0/static/unaccent.html).

Install the unaccent contribution by running the unaccent.sql script. For Ubuntu users, this file is located at /usr/share/postgresql/9.0/contrib/unaccent.sql

Connect to your database and run the following instructions:

CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr
    ALTER MAPPING FOR asciihword, asciiword, hword_asciipart, hword, hword_part, word
    WITH unaccent, french_stem;

Then replace in your default-repository-config.xml file the french analyzer by the one you just defined (fr in this example).

2 votes



If using Postgres 8.4, you can find in the documentation the instructions to build the unaccent module: http://doc.nuxeo.com/display/ADMINDOC/Configuring+PostgreSQL#ConfiguringPostgreSQL-Accentinsensitivefulltextsearch

0 votes