0
0
Fork 0

feat: add fulltextsearch using elasticsearch

This commit is contained in:
p4u1 2023-12-15 19:22:50 +01:00
parent c4ea5e053e
commit 682804c427
3 changed files with 96 additions and 0 deletions

View File

@ -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

View File

@ -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. To start 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 <domain> 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 <domain>
```
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:<password>@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 <domain> app run_occ '"fulltextsearch:test"'
```
6. If the connection was successfull populate the index with data:
```
abra app cmd <domain> 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

View File

@ -0,0 +1,49 @@
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
searchindexer:
image: nextcloud:27.1.3-fpm
volumes:
- nextcloud:/var/www/html/
- nextapps:/var/www/html/custom_apps:cached
- nextdata:/var/www/html/data:cached
- nextconfig:/var/www/html/config:cached
- ${EXTRA_VOLUME}
networks:
- internal
entrypoint: su -p www-data -s /bin/sh -c '/var/www/html/occ fulltextsearch:live'
secrets:
elasticsearch_password:
external: true
name: ${STACK_NAME}_elasticsearch_password_${SECRET_ELASTICSEARCH_PASSWORD_VERSION}
volumes:
elasticsearch: