1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

[#477] User trigram index adjustment.

This commit is contained in:
Ivan Tashkinov 2019-01-18 10:57:42 +03:00
parent ed8f55ab8e
commit 79e44042bc
2 changed files with 14 additions and 1 deletions

View file

@ -744,7 +744,7 @@ defp trigram_search_subquery(query) do
select_merge: %{
search_rank:
fragment(
"similarity(?, ? || ' ' || coalesce(?, ''))",
"similarity(?, trim(? || ' ' || coalesce(?, '')))",
^query,
u.nickname,
u.name

View file

@ -0,0 +1,13 @@
defmodule Pleroma.Repo.Migrations.FixUserTrigramIndex do
use Ecto.Migration
def up do
drop_if_exists index(:users, [], name: :users_trigram_index)
create index(:users, ["(trim(nickname || ' ' || name)) gist_trgm_ops"], name: :users_trigram_index, using: :gist)
end
def down do
drop_if_exists index(:users, [], name: :users_trigram_index)
create index(:users, ["(nickname || name) gist_trgm_ops"], name: :users_trigram_index, using: :gist)
end
end