Search code examples
javahibernatesearchhibernate-searchaccent-insensitive

Search without accents must return words with accents


I have a web app developed with Hibernate, Spring and Java, that accesses an Informix database...

Imagine you are searching for a certain record with an accent on it, like "María", but you write "Maria" in the search box... now it doesn't show any result, but it must show the "María" record, as well as any other combination like "Maríá" or "Máríá" or "Mária", etc...

How could I achieve it? Thanks in advance...


Solution

  • You'll need to add another column with ascii-ized strings and compare it against an ascii-ized search string, but use the primary string as a result. There is no way to convince Informix to do that for you, especially if you want it fetched from an index.

    On a side note, if you had all the strings in Java memory, you could use a SortedMap with a custom, Collator-based Comparator.