Rails:Pg搜索,使用associated_against功能实现dmetaphone

时间:2014-09-23 22:09:48

标签: ruby-on-rails postgresql ruby-on-rails-4 pg-search

创建后:

rails g pg_search:migration:dmetaphone

我收到了这个错误:

Adding support functions for pg_search :dmetaphone
-- execute("CREATE OR REPLACE FUNCTION pg_search_dmetaphone(text) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS $function$\n  SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\\\s+')))), ' ')\n$function$;\n")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedFunction: ERROR:  function dmetaphone(text) does not exist
LINE 2:   SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(rege...

1 个答案:

答案 0 :(得分:1)

听起来您忘了在系统上安装postgresql-contrib软件包。