summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2021-08-28 16:11:52 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2021-08-28 16:11:52 +0000
commit689a59f41f265c08f1aae9784b05747811956775 (patch)
tree08a380bc1a86615f4aee856a839104c1653cba04
parent26abe96abfc9a9035c6d48441978519f199437b9 (diff)
parent4b940e441a4d89c403395b792dd2f806fc80db03 (diff)
Merge branch 'set_text_search_config_timeout' into 'develop'
mix pleroma.database set_text_search_config now runs concurrently and infinitely See merge request pleroma/pleroma!3514
-rw-r--r--docs/configuration/howto_search_cjk.md4
-rw-r--r--lib/mix/tasks/pleroma/database.ex8
2 files changed, 8 insertions, 4 deletions
diff --git a/docs/configuration/howto_search_cjk.md b/docs/configuration/howto_search_cjk.md
index d3ce28077..a73b10db3 100644
--- a/docs/configuration/howto_search_cjk.md
+++ b/docs/configuration/howto_search_cjk.md
@@ -5,7 +5,7 @@ Pleroma's full text search feature is powered by PostgreSQL's native [text searc
## Setup and test the new search config
-In most cases, you would need an extension installed to support parsing CJK text. Here are a few extension you may choose from, or you are more than welcome to share additional ones you found working for you with the rest of Pleroma community.
+In most cases, you would need an extension installed to support parsing CJK text. Here are a few extensions you may choose from, or you are more than welcome to share additional ones you found working for you with the rest of Pleroma community.
* [a generic n-gram parser](https://github.com/huangjimmy/pg_cjk_parser) supports Simplifed/Traditional Chinese, Japanese, and Korean
* [a Korean parser](https://github.com/i0seph/textsearch_ko) based on mecab
@@ -34,7 +34,7 @@ Check output of the query, and see if it matches your expectation.
mix pleroma.database set_text_search_config YOUR.CONFIG
```
-Note: index update may take a while.
+Note: index update may take a while, and it can be done while the instance is up and running, so you may restart db connection as soon as you see `Recreate index` in task output.
## Restart database connection
Since some changes above will only apply with a new database connection, you will have to restart either Pleroma or PostgreSQL process, or use `pg_terminate_backend` SQL command without restarting either.
diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex
index 57f73d12b..a973beaa9 100644
--- a/lib/mix/tasks/pleroma/database.ex
+++ b/lib/mix/tasks/pleroma/database.ex
@@ -209,7 +209,9 @@ defmodule Mix.Tasks.Pleroma.Database do
new.fts_content := to_tsvector(new.data->>'content');
RETURN new;
END
- $$ LANGUAGE plpgsql"
+ $$ LANGUAGE plpgsql",
+ [],
+ timeout: :infinity
)
shell_info("Refresh RUM index")
@@ -219,7 +221,9 @@ defmodule Mix.Tasks.Pleroma.Database do
Ecto.Adapters.SQL.query!(
Pleroma.Repo,
- "CREATE INDEX objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); "
+ "CREATE INDEX CONCURRENTLY objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); ",
+ [],
+ timeout: :infinity
)
end