From 02e3ddf80e36ada4b2e3f19ff852c70d4d1b9a5f Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Tue, 31 Oct 2023 10:24:47 +0100 Subject: [PATCH] apps/contrib: update elasticsearch to 8 --- README.md | 2 +- apps/contrib/elasticsearch.py | 8 ++++---- changelog/_11112.md | 3 +++ requirements/base.txt | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 changelog/_11112.md diff --git a/README.md b/README.md index e4629c32..f8eb6a47 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Start local server with elastic search: Open two terminal windows. 1. Start elastic search in the first one: ``` -$ sudo docker run -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -e "logger.level=DEBUG" docker.elastic.co/elasticsearch/elasticsearch:7.17.10 +$ sudo docker run -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -e "logger.level=DEBUG" -e 'xpack.security.enabled=false' -e 'xpack.security.enrollment.enabled=false' docker.elastic.co/elasticsearch/elasticsearch:8.10.2 ``` 2. Run the server in the second one. But before you do that, update the search index. diff --git a/apps/contrib/elasticsearch.py b/apps/contrib/elasticsearch.py index e490727c..133f998b 100644 --- a/apps/contrib/elasticsearch.py +++ b/apps/contrib/elasticsearch.py @@ -1,9 +1,9 @@ -from wagtail.search.backends.elasticsearch7 import Elasticsearch7SearchBackend -from wagtail.search.backends.elasticsearch7 import Elasticsearch7SearchResults +from wagtail.search.backends.elasticsearch8 import Elasticsearch8SearchBackend +from wagtail.search.backends.elasticsearch8 import Elasticsearch8SearchResults # Code below taken and modified from wagtails elasticsearch backend -class ElasticsearchResults(Elasticsearch7SearchResults): +class ElasticsearchResults(Elasticsearch8SearchResults): def _get_es_body(self, for_count=False): body = { 'query': self.query_compiler.get_query() @@ -51,7 +51,7 @@ def _get_results_from_hits(self, hits): yield result -class ElasticsearchCustomSearchBackend(Elasticsearch7SearchBackend): +class ElasticsearchCustomSearchBackend(Elasticsearch8SearchBackend): results_class = ElasticsearchResults diff --git a/changelog/_11112.md b/changelog/_11112.md new file mode 100644 index 00000000..55d2e01b --- /dev/null +++ b/changelog/_11112.md @@ -0,0 +1,3 @@ +### Changed + +- update to elasticsearch 8 diff --git a/requirements/base.txt b/requirements/base.txt index 16982d1f..bd14c27c 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -7,6 +7,6 @@ django-widget-tweaks==1.4.12 sentry-sdk==1.32.0 wagtail==5.1.3 whitenoise==6.6.0 -elasticsearch==7.17.9 +elasticsearch==8.10.1 wagtail-metadata==4.0.3 sib-api-v3-sdk==7.6.0