Skip to content

Commit 315d90f

Browse files
Fix, add es6 docker image and compose
1 parent b0c0b82 commit 315d90f

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

docker-compose-es-6-8.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
3+
services:
4+
5+
elasticsearch:
6+
container_name: django_elasticsearch_dsl_drf_elasticsearch_es_6_8
7+
build:
8+
context: .
9+
dockerfile: ./docker/elasticsearch/Dockerfile-ES-6-8
10+
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.15
11+
volumes:
12+
- esdata68:/usr/share/elasticsearch/data
13+
ports:
14+
- "9200:9200"
15+
- "9300:9300"
16+
environment:
17+
# - bootstrap.memory_lock=true
18+
- discovery.type=single-node
19+
- xpack.security.enabled=false
20+
- cluster.routing.allocation.disk.watermark.low=97%
21+
- cluster.routing.allocation.disk.watermark.high=98%
22+
- cluster.routing.allocation.disk.watermark.flood_stage=99%
23+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
24+
25+
volumes:
26+
esdata68:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM docker.elastic.co/elasticsearch/elasticsearch:6.8.15
2+
ADD ./docker/elasticsearch/elasticsearch.yml /usr/share/elasticsearch/config/
3+
USER root
4+
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
5+
USER elasticsearch

src/django_elasticsearch_dsl_drf/viewsets.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,12 @@ def get_object(self):
217217

218218
if not obj and self.ignore:
219219
raise Http404("No result matches the given query.")
220-
# TODO: Do we need obj on != ELASTICSEARCH_GTE_7_0 like below?
221-
if ELASTICSEARCH_GTE_7_0:
222-
dictionary_proxy = self.dictionary_proxy(
223-
obj.to_dict(),
224-
obj.meta
225-
)
226-
else:
227-
dictionary_proxy = self.dictionary_proxy(obj, obj.meta)
220+
# Remark 1: Code below works fine. Do not try to do the same as
221+
# done in `Remark 2`.
222+
dictionary_proxy = self.dictionary_proxy(
223+
obj.to_dict(),
224+
getattr(obj, 'meta', None)
225+
)
228226
return dictionary_proxy
229227
else:
230228
queryset = queryset.filter(
@@ -241,6 +239,8 @@ def get_object(self):
241239
# May raise a permission denied
242240
self.check_object_permissions(self.request, obj)
243241

242+
# Remark 2: Unlike code in `Remark 1`, here we do need the
243+
# conditional treatment.
244244
if ELASTICSEARCH_GTE_7_0:
245245
dictionary_proxy = self.dictionary_proxy(
246246
obj.to_dict(),

0 commit comments

Comments
 (0)