Support for setting PGroonga indexing options
This commit is contained in:
parent
3859c4bbcf
commit
2634723958
2 changed files with 40 additions and 34 deletions
|
@ -331,12 +331,10 @@ def run(["set_text_search_config", tsconfig]) do
|
|||
shell_info("Error: #{inspect(msg, pretty: true)}")
|
||||
else
|
||||
rum_enabled = Pleroma.Config.get([:database, :rum_enabled])
|
||||
pgroonga_enabled = Pleroma.Config.get([:database, :pgroonga_enabled])
|
||||
shell_info("Recreate index, RUM: #{rum_enabled}, PGroonga: #{pgroonga_enabled}")
|
||||
shell_info("Recreate index, RUM: #{rum_enabled}")
|
||||
|
||||
# Note SQL below needs to be kept up-to-date with latest GIN or RUM index definition in future
|
||||
cond do
|
||||
rum_enabled ->
|
||||
if rum_enabled do
|
||||
Ecto.Adapters.SQL.query!(
|
||||
Pleroma.Repo,
|
||||
"CREATE OR REPLACE FUNCTION objects_fts_update() RETURNS trigger AS $$ BEGIN
|
||||
|
@ -350,18 +348,7 @@ def run(["set_text_search_config", tsconfig]) do
|
|||
|
||||
shell_info("Refresh RUM index")
|
||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "UPDATE objects SET updated_at = NOW();")
|
||||
|
||||
pgroonga_enabled ->
|
||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "DROP INDEX IF EXISTS object_content_pgroonga;")
|
||||
|
||||
Ecto.Adapters.SQL.query!(
|
||||
Pleroma.Repo,
|
||||
"CREATE INDEX object_content_pgroonga ON objects USING pgroonga ((data->'content')) WITH (tokenizer='TokenMecab');",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
|
||||
true ->
|
||||
else
|
||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "DROP INDEX IF EXISTS objects_fts;")
|
||||
|
||||
Ecto.Adapters.SQL.query!(
|
||||
|
@ -376,6 +363,27 @@ def run(["set_text_search_config", tsconfig]) do
|
|||
end
|
||||
end
|
||||
|
||||
def run(["set_pgroonga_options", pg_options]) do
|
||||
start_pleroma()
|
||||
pgroonga_enabled = Pleroma.Config.get([:database, :pgroonga_enabled])
|
||||
|
||||
if pgroonga_enabled do
|
||||
shell_info("Recreate index with options #{pg_options}")
|
||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "DROP INDEX IF EXISTS object_content_pgroonga;")
|
||||
|
||||
Ecto.Adapters.SQL.query!(
|
||||
Pleroma.Repo,
|
||||
"CREATE INDEX object_content_pgroonga ON objects USING pgroonga ((data->'content')) WITH (#{pg_options});",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
|
||||
shell_info('Done.')
|
||||
else
|
||||
shell_info('PGroonga is not enabled.')
|
||||
end
|
||||
end
|
||||
|
||||
# Rolls back a specific migration (leaving subsequent migrations applied).
|
||||
# WARNING: imposes a risk of unrecoverable data loss — proceed at your own responsibility.
|
||||
# Based on https://stackoverflow.com/a/53825840
|
||||
|
|
|
@ -11,9 +11,7 @@ def up do
|
|||
)
|
||||
)
|
||||
|
||||
execute(
|
||||
"CREATE INDEX object_content_pgroonga ON objects USING pgroonga ((data->'content')) WITH (tokenizer='TokenMecab')"
|
||||
)
|
||||
execute("CREATE INDEX object_content_pgroonga ON objects USING pgroonga ((data->'content'))")
|
||||
end
|
||||
|
||||
def down do
|
||||
|
|
Loading…
Reference in a new issue