From 95e7f04cf5edf6ec573b2d64ed77ae9d44b15609 Mon Sep 17 00:00:00 2001 From: Christian Galo Date: Wed, 25 Nov 2026 02:35:21 +0000 Subject: [PATCH] docs: fix full text search setup order and elastic_host password The live indexer must be stopped until fulltextsearch:index has created the index; otherwise Elasticsearch auto-creates it without the app mappings and the attachment pipeline, and file contents are never indexed. The elastic_host command now reads the secret inside the container instead of on the host. Also enable files_group_folders and document how to rebuild the index. --- README.md | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0ca0f95..7ed0375 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,12 @@ export NC_APP="docker exec -u www-data -it $(docker ps --filter name=${STACK_NAM export NC_DB="docker exec -it $(docker ps --filter name=${STACK_NAME}_db --format '{{.ID}}' | head -n 1)" ``` +Stop the live indexer until the index is built. If it runs first, Elasticsearch creates the index on its own, without the app's mappings and without the `attachment` pipeline, and file contents never become searchable: + +``` +docker service scale ${STACK_NAME}_searchindexer=0 +``` + Next, run the following commands to install and configure the necessary Nextcloud apps for full text search with Elasticsearch: ``` @@ -105,11 +111,14 @@ $NC_APP php /var/www/html/occ app:install fulltextsearch_elasticsearch $NC_APP php /var/www/html/occ app:install files_fulltextsearch $NC_APP php /var/www/html/occ config:app:set fulltextsearch search_platform --value="OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform" -$NC_APP php /var/www/html/occ config:app:set fulltextsearch_elasticsearch elastic_host --value="http://elastic:$(cat /run/secrets/elasticsearch_password)@elasticsearch:9200/" +$NC_APP sh -c 'php /var/www/html/occ config:app:set fulltextsearch_elasticsearch elastic_host --value="http://elastic:$(cat /run/secrets/elasticsearch_password)@elasticsearch:9200/"' $NC_APP php /var/www/html/occ config:app:set fulltextsearch_elasticsearch elastic_index --value="nextcloud" $NC_APP php /var/www/html/occ config:app:set files_fulltextsearch files_local --value="1" +$NC_APP php /var/www/html/occ config:app:set files_fulltextsearch files_group_folders --value=true --type=boolean ``` +Without `files_group_folders`, files in group folders are indexed by name only. + Verify the setup by running: ``` @@ -122,14 +131,38 @@ Then, check for connectivity with Elasticsearch: $NC_APP php /var/www/html/occ fulltextsearch:test ``` -Manually build the search index: +Manually build the search index. This creates the index and the `attachment` pipeline, then indexes every file: ``` $NC_APP php /var/www/html/occ fulltextsearch:index ``` -If you get “Index is already running”, clear the ticker table in the database: +Then start the live indexer again: ``` -$NC_DB sh -c 'echo "delete from oc_fulltextsearch_ticks;" | mariadb -u root -p$(cat /run/secrets/db_root_password) nextcloud' +docker service scale ${STACK_NAME}_searchindexer=1 +``` + +If you get “Index is already running”, a killed indexer left its lock behind. Clear it with: + +``` +$NC_APP php /var/www/html/occ fulltextsearch:stop +``` + +### Rebuilding the Search Index + +If search only finds file names and not file contents, check that the pipeline exists. This should print `200`: + +``` +$NC_APP sh -c 'curl -s -o /dev/null -w "%{http_code}\n" -u elastic:$(cat /run/secrets/elasticsearch_password) http://elasticsearch:9200/_ingest/pipeline/attachment' +``` + +If it prints `404`, rebuild the index. The reset asks twice; the second time, type `reset ALL ALL`: + +``` +docker service scale ${STACK_NAME}_searchindexer=0 +$NC_APP php /var/www/html/occ fulltextsearch:stop +$NC_APP php /var/www/html/occ fulltextsearch:reset +$NC_APP php /var/www/html/occ fulltextsearch:index +docker service scale ${STACK_NAME}_searchindexer=1 ```