Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump required Elasticsearch to 7.* #935

Merged
merged 8 commits into from Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@

## Changed

- Bumped Elasticsearch requirement to 7.\*
- AIP creation to be done at preservation step
- Relation between IPs and storage policies to be defined in submission agreement

Expand Down
6 changes: 3 additions & 3 deletions ESSArch_Core/ip/views.py
Expand Up @@ -1804,9 +1804,9 @@ def files(self, request, pk=None):
raise

if self.paginator is not None:
ceil = math.ceil(results.hits.total / size)
ceil = math.ceil(results.hits.total['value'] / size)
ceil = 1 if ceil < 1 else ceil
if results.hits.total > 0 and number > ceil:
if results.hits.total['value'] > 0 and number > ceil:
raise exceptions.NotFound('Invalid page.')

results_list = []
Expand All @@ -1827,7 +1827,7 @@ def files(self, request, pk=None):
results_list.append(d)

if self.paginator is not None:
return Response(results_list, headers={'Count': results.hits.total})
return Response(results_list, headers={'Count': results.hits.total['value']})

return Response(results_list)

Expand Down
5 changes: 1 addition & 4 deletions ESSArch_Core/search/alias_migration.py
Expand Up @@ -5,7 +5,6 @@
"""
from datetime import datetime

from elasticsearch_dsl import IndexTemplate
from elasticsearch_dsl.connections import get_connection


Expand Down Expand Up @@ -65,9 +64,7 @@ def migrate(doctype, move_data=True, update_alias=True, delete_old_index=False):
next_index = get_next_index(pattern)

# create an index template
index_template = IndexTemplate(alias, pattern)
# add the DocType mappings
index_template.doc_type(doctype)
index_template = doctype._index.as_template(alias, pattern)
# upload the template into elasticsearch
# potentially overriding the one already there
index_template.save()
Expand Down
2 changes: 1 addition & 1 deletion ESSArch_Core/search/documents.py
Expand Up @@ -108,7 +108,7 @@ def remove_stale(cls, queryset, batch_size):
db_ids = list(queryset.values_list('id', flat=True))
s = cls.search()
resp = s.execute()
total_index = resp.hits.total
total_index = resp.hits.total['value']
removed = []
for start in range(0, total_index, batch_size):
end = start + batch_size
Expand Down
4 changes: 2 additions & 2 deletions ESSArch_Core/tags/search.py
Expand Up @@ -424,7 +424,7 @@ def list(self, request):
raise

if self.paginator is not None:
if size > 0 and results.hits.total > 0 and number > math.ceil(results.hits.total / size):
if size > 0 and results.hits.total['value'] > 0 and number > math.ceil(results.hits.total['value'] / size):
raise exceptions.NotFound('Invalid page.')

results_dict = results.to_dict()
Expand All @@ -440,7 +440,7 @@ def list(self, request):
if export is not None:
return self.generate_report(results_dict['hits']['hits'], export, request.user)

return Response(r, headers={'Count': results.hits.total})
return Response(r, headers={'Count': results.hits.total['value']})

def generate_report(self, hits, format, user):
try:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Expand Up @@ -147,7 +147,7 @@ services:
build:
context: elasticsearch
args:
ELK_VERSION: 6.5.4
ELK_VERSION: 7.5.2
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- essarch_elasticsearch_data:/usr/share/elasticsearch/data
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Expand Up @@ -27,7 +27,7 @@ distro==1.4.0
drf-dynamic-fields==0.3.1
drf-extensions==0.6.0
drf-proxy-pagination==0.2.0
elasticsearch-dsl==6.3.1
elasticsearch-dsl==7.1.0
glob2==0.7
jsonfield2==3.1.0
lxml==4.4.2
Expand Down