문제

Is it possible to execute a MySQL query using "=" or "like" operations that ignore accentuation?

Example:

select * from address where name like "Rua Tabapua"

returns

Rua Tabapuá Rua Tabapuã Rua Tabapuà

and etc...

Is it possible to do it using Ruby on Rails ActiveRecord API without using find_by_sql?

Thanks,

Rubem

도움이 되었습니까?

해결책 3

You can do that by using UTF-8 and like queries

다른 팁

Even if there is probably some ways to do it in MySQL, if you want to do full text searching, maybe it would be easier to use a full text indexing engine like Sphinx and Thinking Sphinx.

When indexing via Sphinx, you can configure it so it would ignore accentuated characters and so on...

This sounds as a mysql configuration question. Check the mysql.log file when this query is done. You'll see the query is made as you wish, but mysql returns more results than you expect. Try the query in mysql console and you'll see same thing happens.

And all that in a layer below Ruby on Rails.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top