|
1 | 1 | import collections
|
2 | 2 | from types import MethodType
|
3 |
| -import warnings |
4 | 3 |
|
5 | 4 | from django.core.exceptions import ObjectDoesNotExist
|
6 | 5 | from django.db import models
|
7 | 6 | from django.db.models.fields.files import FieldFile
|
8 | 7 | from django.utils.encoding import force_text
|
9 | 8 | from django.utils.functional import Promise
|
10 |
| - |
11 | 9 | from elasticsearch_dsl.field import (
|
12 | 10 | Boolean,
|
13 | 11 | Byte,
|
|
24 | 22 | Nested,
|
25 | 23 | Object,
|
26 | 24 | Short,
|
| 25 | + Keyword, |
| 26 | + Text |
27 | 27 | )
|
| 28 | + |
28 | 29 | from .exceptions import VariableLookupError
|
29 | 30 |
|
30 | 31 |
|
@@ -210,61 +211,13 @@ def get_value_from_instance(self, instance, field_value_to_ignore=None):
|
210 | 211 | return _file if _file else ''
|
211 | 212 |
|
212 | 213 |
|
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 |
253 | 216 |
|
254 | 217 |
|
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 |
258 | 220 |
|
259 |
| - class AttachmentField(DEDField, Attachment): |
260 |
| - pass |
261 |
| -except ImportError: |
262 |
| - from elasticsearch_dsl.field import Text |
263 | 221 |
|
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