Skip to content

Commit ba441ce

Browse files
authored
[Fix #201] Removing old elasticsearc compatibility (#219)
* Removing old elasticsearc compatibility * Fixing import
1 parent 8cbc4ce commit ba441ce

File tree

1 file changed

+9
-56
lines changed

1 file changed

+9
-56
lines changed

django_elasticsearch_dsl/fields.py

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import collections
22
from types import MethodType
3-
import warnings
43

54
from django.core.exceptions import ObjectDoesNotExist
65
from django.db import models
76
from django.db.models.fields.files import FieldFile
87
from django.utils.encoding import force_text
98
from django.utils.functional import Promise
10-
119
from elasticsearch_dsl.field import (
1210
Boolean,
1311
Byte,
@@ -24,7 +22,10 @@
2422
Nested,
2523
Object,
2624
Short,
25+
Keyword,
26+
Text
2727
)
28+
2829
from .exceptions import VariableLookupError
2930

3031

@@ -210,61 +211,13 @@ def get_value_from_instance(self, instance, field_value_to_ignore=None):
210211
return _file if _file else ''
211212

212213

213-
# ES5+ has text types Keyword and Text, ES2 has type String.
214-
try:
215-
from elasticsearch_dsl.field import Keyword, Text
216-
217-
class KeywordField(DEDField, Keyword):
218-
pass
219-
220-
class TextField(DEDField, Text):
221-
pass
222-
223-
class StringField(DEDField, Text):
224-
warnings.warn(
225-
'StringField is deprecated in Elasticsearch 5 and removed in '
226-
'Elasticsearch 6. Please use TextField and KeywordField instead.',
227-
DeprecationWarning
228-
)
229-
230-
class FileField(FileFieldMixin, DEDField, Text):
231-
pass
232-
233-
234-
except ImportError:
235-
from elasticsearch_dsl.field import String
236-
237-
class KeywordField(DEDField, String):
238-
def __init__(self, **kwargs):
239-
if 'index' not in kwargs or kwargs['index'] is True:
240-
# Unless a custom 'index' setting was provided, create the
241-
# Keyword field as a "not_analyzed" field.
242-
kwargs['index'] = 'not_analyzed'
243-
super(KeywordField, self).__init__(**kwargs)
244-
245-
class TextField(DEDField, String):
246-
pass
247-
248-
class StringField(DEDField, String):
249-
pass
250-
251-
class FileField(FileFieldMixin, DEDField, String):
252-
pass
214+
class KeywordField(DEDField, Keyword):
215+
pass
253216

254217

255-
# Elasticsearch 2 and 5 have an Attachment field, ES 6 doesn't.
256-
try:
257-
from elasticsearch_dsl.field import Attachment
218+
class TextField(DEDField, Text):
219+
pass
258220

259-
class AttachmentField(DEDField, Attachment):
260-
pass
261-
except ImportError:
262-
from elasticsearch_dsl.field import Text
263221

264-
class AttachmentField(DEDField, Text):
265-
name = 'attachment'
266-
warnings.warn(
267-
'AttachmentField is deprecated in Elasticsearch 5 and removed in '
268-
'Elasticsearch 6.',
269-
DeprecationWarning
270-
)
222+
class FileField(FileFieldMixin, DEDField, Text):
223+
pass

0 commit comments

Comments
 (0)