Upgrade NIP-50 search to ranked Postgres FTS

This commit is contained in:
2026-03-18 15:56:45 +01:00
parent f732d9cf24
commit bc66dfcbbe
4 changed files with 219 additions and 19 deletions

View File

@@ -0,0 +1,27 @@
defmodule Parrhesia.Repo.Migrations.AddNip50FtsAndTrigramSearch do
use Ecto.Migration
def up do
execute("CREATE EXTENSION IF NOT EXISTS pg_trgm")
execute("""
CREATE INDEX events_content_fts_idx
ON events
USING GIN (to_tsvector('simple', content))
WHERE deleted_at IS NULL
""")
execute("""
CREATE INDEX events_content_trgm_idx
ON events
USING GIN (content gin_trgm_ops)
WHERE deleted_at IS NULL
""")
end
def down do
execute("DROP INDEX IF EXISTS events_content_trgm_idx")
execute("DROP INDEX IF EXISTS events_content_fts_idx")
execute("DROP EXTENSION IF EXISTS pg_trgm")
end
end