使用Ecto和PostgreSQL忽略全文搜索中的重音时出错

时间:2016-10-04 12:17:41

标签: postgresql elixir phoenix-framework ecto

我的控制器中有这个搜索功能:

def search(query, search_term) do
    (from u in query,
    where: fragment("(to_tsvector('portuguese', unaccent(?)) @@ plainto_tsquery(?))", u.name, ^search_term),
    order_by: fragment("ts_rank((to_tsvector('portuguese', unaccent(?)), plainto_tsquery(?))) DESC", u.name, ^search_term))
  end

我收到此错误:

ERROR (undefined_function): function unaccent(character varying) does not exist

我还在PostgreSQL中添加了unaccented扩展名:

CREATE EXTENSION unaccent;

如何使这项工作?

0 个答案:

没有答案