Question

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...

Was it helpful?

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.

OTHER TIPS

When you need to search a database via Hibernate and have concerns about accents, an interest in better natural language matches, or simply want to explore options like auto-suggestion or typo corrections you should look at Hibernate Search which automates most of this via a couple of annotations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top