PFC wrote: >> 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.
Creating an extra column which holds a copy of the data is certainly not a very good idea, as it will create unnecessary redundancy (breaking normal forms), bloat your table, and the trigger will have a certain performance impact. My suggestion is to write a function that removes the accents in a string for your language, let's call it noaccents(text). Then you can index the column atext with CREATE INDEX atable_atext_idx ON atable ((noaccents(atext))) Then every query of the form ... WHERE noaccents(atext) = noaccents('SOMÉTHING') can use the index. Yours, Laurenz Albe ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly