From fc965f982c62c43e11cb42c77f7c371c9835a9f2 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Tue, 15 Jan 2019 12:04:54 +0300 Subject: [#477] Added FTS index for `users`. Fixed failing test. --- .../migrations/20190115085500_create_user_fts_index.exs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 priv/repo/migrations/20190115085500_create_user_fts_index.exs (limited to 'priv/repo/migrations/20190115085500_create_user_fts_index.exs') diff --git a/priv/repo/migrations/20190115085500_create_user_fts_index.exs b/priv/repo/migrations/20190115085500_create_user_fts_index.exs new file mode 100644 index 000000000..499d67113 --- /dev/null +++ b/priv/repo/migrations/20190115085500_create_user_fts_index.exs @@ -0,0 +1,17 @@ +defmodule Pleroma.Repo.Migrations.CreateUserFtsIndex do + use Ecto.Migration + + def change do + create index( + :users, + [ + """ + (setweight(to_tsvector('simple', regexp_replace(nickname, '\\W', ' ', 'g')), 'A') || + setweight(to_tsvector('simple', regexp_replace(coalesce(name, ''), '\\W', ' ', 'g')), 'B')) + """ + ], + name: :users_fts_index, + using: :gin + ) + end +end -- cgit v1.2.3