| От | PFC |
|---|---|
| Тема | Re: Accent insensitive search |
| Дата | |
| Msg-id | op.tt9m8upxcigqcu@apollo13 обсуждение исходный текст |
| Ответ на | Accent insensitive search (Diego Manilla Suárez <diego.manilla@xeridia.com>) |
| Ответы |
Re: Accent insensitive search
|
| Список | pgsql-general |
> Hi. I have a few databases created with UNICODE encoding, and I would
> like to be able to search with accent insensitivity. There's something
> in Oracle (NLS_COMP, NLS_SORT) and SQL Server (don't remember) to do
> this, but I found nothing in PostgreSQL, just the 'to_ascii' function,
> which AFAIK, doesn't work with UNICODE.
The easiest way is to create an extra column which will hold a copy of
your text, with all accents removed. You can also convert it to lowercase
and remove apostrophes, punctuation etc. Said column is kept up to date
with a trigger.
Python is suitable for this (use unicodedata.normalize).
Keeping a copy of the processed data will speed up search versus WHERE
remove_accents( blah ) = 'text', even with a function index.
Note that this function could be written in C and use a table on the
first 64K unicode symbols for speedup.
See attached file.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера