Skip to content

Instantly share code, notes, and snippets.

@derencius
Created May 26, 2011 01:31
Show Gist options
  • Save derencius/992375 to your computer and use it in GitHub Desktop.
Save derencius/992375 to your computer and use it in GitHub Desktop.
Unaccent PostgreSQL 8.4
-- Adjust this setting to control where the objects get created.
SET search_path = public;
-- Standalone 'unaccent' function
CREATE OR REPLACE FUNCTION unaccent (text) RETURNS text
AS '/usr/lib64/pgsql/unaccent'
LANGUAGE C IMMUTABLE STRICT;
-- New 'unaccentdict' dictionary for text search indexer
CREATE OR REPLACE FUNCTION dunaccentdict_init(internal)
RETURNS internal
AS '/usr/lib64/pgsql/unaccent'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION dunaccentdict_lexize(internal, internal, internal, internal)
RETURNS internal
AS '/usr/lib64/pgsql/unaccent'
LANGUAGE C STRICT;
CREATE TEXT SEARCH TEMPLATE unaccentdict_template (
LEXIZE = dunaccentdict_lexize,
INIT = dunaccentdict_init
);
CREATE TEXT SEARCH DICTIONARY unaccentdict (
TEMPLATE = unaccentdict_template
);
COMMENT ON TEXT SEARCH DICTIONARY unaccentdict IS 'unaccenting dictionary';
CREATE TEXT SEARCH CONFIGURATION unaccented_portuguese ( COPY = portuguese );
ALTER TEXT SEARCH CONFIGURATION unaccented_portuguese
ALTER MAPPING FOR hword, hword_part, word
WITH unaccentdict, portuguese_stem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment