From ca2bf962e9c48992b78eb52a3bae4482c0e03393 Mon Sep 17 00:00:00 2001 From: jonaswinkler <17569239+jonaswinkler@users.noreply.github.com> Date: Mon, 5 Apr 2021 21:33:17 +0200 Subject: [PATCH] force update of search index if out of date --- docker/docker-entrypoint.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 5919b14aa..cf6129438 100644 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -68,6 +68,17 @@ migrations() { } +search_index() { + index_version=1 + index_version_file=/usr/src/paperless/data/.index_version + + if [[ (! -f "$index_version_file") || $(< $index_version_file) != "$index_version" ]]; then + echo "Search index out of date. Updating..." + sudo -HEu paperless python3 manage.py document_index reindex + echo $index_version | sudo -HEu paperless tee $index_version_file >/dev/null + fi +} + initialize() { map_uidgid @@ -87,6 +98,7 @@ initialize() { migrations + search_index } install_languages() {