Postgres accent insensitive LIKE search in Rails 3.1 on Heroku

后端 未结 5 2116
无人及你
无人及你 2021-02-05 11:11

How can I modify a where/like condition on a search query in Rails:

find(:all, :conditions => [\"lower(name) LIKE ?\", \"%#{search.downcase}%\"])

5条回答
  •  不思量自难忘°
    2021-02-05 11:40

    There are 2 questions related to your search on the StackExchange: https://serverfault.com/questions/266373/postgresql-accent-diacritic-insensitive-search

    But as you are on Heroku, I doubt this is a good match (unless you have a dedicated database plan).

    There is also this one on SO: Removing accents/diacritics from string while preserving other special chars.

    But this assumes that your data is stored without any accent.

    I hope it will point you in the right direction.

提交回复
热议问题