unaccent

Postgres accent insensitive LIKE search in Rails 3.1 on Heroku

北慕城南 提交于 2019-12-20 17:42:30
问题 How can I modify a where/like condition on a search query in Rails: find(:all, :conditions => ["lower(name) LIKE ?", "%#{search.downcase}%"]) so that the results are matched irrespective of accents? (eg métro = metro). Because I'm using utf8, I can't use "to_ascii". Production is running on Heroku. 回答1: Poor man's solution If you are able to create a function, you can use this one. I compiled the list starting here and added to it over time. It is pretty complete. You may even want to remove

unaccent() preventing index usage in Postgres

橙三吉。 提交于 2019-12-19 09:47:15
问题 I want to retrieve a way with a given name from an OpenStreetMap database imported into PostgreSQL 9.3.5, the OS is Win7 64-bit. In order to be a bit failure tolerant, I use the unaccent extension of Postgres. My query looks as follows: SELECT * FROM germany.ways WHERE lower(tags->'name') like lower(unaccent('unaccent','Weststrasse')) Query plan: Seq Scan on ways (cost=0.00..2958579.31 rows=122 width=465) Filter: (lower((tags -> 'name'::text)) ~~ lower(unaccent('unaccent'::regdictionary,

Error when creating unaccent extension on PostgreSQL

China☆狼群 提交于 2019-12-17 10:52:08
问题 I am trying to configure PostgreSQL to use fulltext search in my rails app as mentioned in this Railscast. I am using a fresh Ubuntu 12.04 server running PostgreSQL 9.1.5 installed using apt-get with the ppa:pitti/postgresql with precise . I get the following error when trying to run the migration and when I try the same command in the psql console with the peer postgres user: postgres=# CREATE EXTENSION unaccent; ERROR: could not open extension control file "/usr/share/postgresql/9.1

Postgresql levenshtein and precomposed character vs. combined character

假如想象 提交于 2019-12-11 04:05:41
问题 I have Strings containing two similar looking characters. Both appear as small 'a's with an ogonek: ą ą (Note: depending on the renderer they are sometimes rendered similarily, sometimes slightly differently) However, they are different: Characteristics of the 1st character: In PostgreSQL: select ascii('ą'); ascii ------- 261 The UTF-8-encoding in Hex is: \xC4\x85 so it is a precomposed character (https://en.wikipedia.org/wiki/Precomposed_character) Characteristics of the 2nd character: In

Postgres accent insensitive LIKE search in Rails 3.1 on Heroku

与世无争的帅哥 提交于 2019-12-03 05:15:17
How can I modify a where/like condition on a search query in Rails: find(:all, :conditions => ["lower(name) LIKE ?", "%#{search.downcase}%"]) so that the results are matched irrespective of accents? (eg métro = metro). Because I'm using utf8, I can't use "to_ascii". Production is running on Heroku. Erwin Brandstetter Poor man's solution If you are able to create a function, you can use this one. I compiled the list starting here and added to it over time. It is pretty complete. You may even want to remove some characters: CREATE OR REPLACE FUNCTION lower_unaccent(text) RETURNS text AS $func$

Error when creating unaccent extension on PostgreSQL

那年仲夏 提交于 2019-11-27 13:27:06
I am trying to configure PostgreSQL to use fulltext search in my rails app as mentioned in this Railscast . I am using a fresh Ubuntu 12.04 server running PostgreSQL 9.1.5 installed using apt-get with the ppa:pitti/postgresql with precise . I get the following error when trying to run the migration and when I try the same command in the psql console with the peer postgres user: postgres=# CREATE EXTENSION unaccent; ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/unaccent.control": No such file or directory In my local box running Ubuntu 10.04 desktop I use the