Skip to content

Commit

Permalink
apps/contrib: update elasticsearch to 8
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk authored and philli-m committed Oct 31, 2023
1 parent 307ef15 commit 02e3ddf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions apps/contrib/elasticsearch.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -51,7 +51,7 @@ def _get_results_from_hits(self, hits):
yield result


class ElasticsearchCustomSearchBackend(Elasticsearch7SearchBackend):
class ElasticsearchCustomSearchBackend(Elasticsearch8SearchBackend):
results_class = ElasticsearchResults


Expand Down
3 changes: 3 additions & 0 deletions changelog/_11112.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- update to elasticsearch 8
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 02e3ddf

Please sign in to comment.