From d03895c872380e526aae66b18ad5ce20c293423c Mon Sep 17 00:00:00 2001 From: p4u1 Date: Fri, 15 Dec 2023 19:22:50 +0100 Subject: [PATCH] feat: add elasticsearch --- .env.sample | 3 +++ README.md | 44 ++++++++++++++++++++++++++++++++++++++ compose.elasticsearch.yaml | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 compose.elasticsearch.yaml diff --git a/.env.sample b/.env.sample index 00da3fd..ec96d56 100644 --- a/.env.sample +++ b/.env.sample @@ -62,3 +62,6 @@ DEFAULT_QUOTA="10 GB" # AUTHENTIK_DOMAIN=authentik.example.com # SECRET_AUTHENTIK_SECRET_VERSION=v1 # SECRET_AUTHENTIK_ID_VERSION=v1 + +#COMPOSE_FILE="$COMPOSE_FILE:compose.elasticsearch.yml" +#SECRET_ELASTICSEARCH_PASSWORD_VERSION=v1 diff --git a/README.md b/README.md index 2f7d17a..a913eb5 100644 --- a/README.md +++ b/README.md @@ -244,3 +244,47 @@ docker exec -u www-data $(docker ps -f name=foo_com_app -q) ./occ preview:pre-ge ``` This app will improve performance of image browsing at the cost of storage space. + +## Fulltextsearch with elasticsearch + +1. For this you need to install these apps: +- [fulltextsearch](https://github.com/nextcloud/fulltextsearch) +- [fulltextsearch_elasticsearch](https://github.com/nextcloud/fulltextsearch_elasticsearch) +- [files_fulltextsearch](https://github.com/nextcloud/files_fulltextsearch) + +2. To enable the elasticsearch index uncomment the following lines in your env file: +``` +#COMPOSE_FILE="$COMPOSE_FILE:compose.elasticsearch.yml" +#SECRET_ELASTICSEARCH_PASSWORD_VERSION=v1 +``` + +3. Next you need to generate the secret for elasticsearch: +```bash +abra app secret generate elasticsearch_password v1 +``` + +You need to write down the password, since you need this later! + +4. Now you can deploy your app: +```bash +abra app deploy +``` + +5. After the deployment finished go to the settings page for fulltext and configure it: + +- Set `Search Platform` to `Elasticsearch` +- Set `Address of the Servlet` to `http://elastic:@elasticsearch:9200/` +- Set `Index` to a random index name +- Select what should be index + +6. Now test if nextcloud can connect to elasticsearch: +``` +abra app cmd app run_occ '"fulltextsearch:test"' +``` + +6. If the connection was successfull populate the index with data: +``` +abra app cmd app run_occ '"fulltextsearch:index"' +``` + +7. Check if the search works correctly by searching for a word which occurs in a file on your nextcloud diff --git a/compose.elasticsearch.yaml b/compose.elasticsearch.yaml new file mode 100644 index 0000000..4323b88 --- /dev/null +++ b/compose.elasticsearch.yaml @@ -0,0 +1,37 @@ +version: "3.8" + +services: + elasticsearch: + image: "docker.elastic.co/elasticsearch/elasticsearch:8.11.3" + environment: + - cluster.name=docker-cluster + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - discovery.type=single-node + # Disable authentication and ssl completely + # - xpack.security.enabled=false + # Use this to enable Basic Authentication: + - xpack.security.enabled=true + - xpack.security.http.ssl.enabled=false + - ELASTIC_PASSWORD_FILE=/var/run/secrets/elasticsearch_password + ulimits: + memlock: + soft: -1 + hard: -1 + volumes: + - elasticsearch:/usr/share/elasticsearch/data + networks: + - internal + secrets: + - source: elasticsearch_password + uid: "1000" + gid: "1000" + mode: 0600 + +secrets: + elasticsearch_password: + external: true + name: ${STACK_NAME}_elasticsearch_password_${SECRET_ELASTICSEARCH_PASSWORD_VERSION} + +volumes: + elasticsearch: