Skip to content

Commit 118e9bc

Browse files
committed
Use elasticsearch-dsl >= 7.0.0
1 parent 754fec9 commit 118e9bc

14 files changed

+69
-83
lines changed

.travis.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ dist: trusty # default "precise" distro doesn't include Java 8 for Elasticsearch
77

88
matrix:
99
include:
10-
- env: TOX_ENV=py36-django-110-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
10+
- env: TOX_ENV=py36-django-110-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
1111
python: 3.6
12-
- env: TOX_ENV=py37-django-110-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
12+
- env: TOX_ENV=py37-django-110-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
1313
python: 3.7
1414
sudo: true
1515
dist: xenial
16-
- env: TOX_ENV=py27-django-110-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
16+
- env: TOX_ENV=py27-django-110-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
1717
python: 2.7
18-
- env: TOX_ENV=py36-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
18+
- env: TOX_ENV=py36-django-111-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
1919
python: 3.6
20-
- env: TOX_ENV=py37-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
20+
- env: TOX_ENV=py37-django-111-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
2121
python: 3.7
2222
sudo: true
2323
dist: xenial
24-
- env: TOX_ENV=py27-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
24+
- env: TOX_ENV=py27-django-111-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
2525
python: 2.7
26-
- env: TOX_ENV=py36-django-2-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
26+
- env: TOX_ENV=py36-django-2-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
2727
python: 3.6
28-
- env: TOX_ENV=py37-django-2-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
28+
- env: TOX_ENV=py37-django-2-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
2929
python: 3.7
3030
sudo: true
3131
dist: xenial
32-
- env: TOX_ENV=py37-django-21-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
32+
- env: TOX_ENV=py37-django-21-es7 ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
3333
python: 3.7
3434
dist: xenial
3535
sudo: true

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Features
2727

2828
- Django >= 1.10
2929
- Python 2.7, 3.5, 3.6, 3.7
30-
- Elasticsearch >= 6.0 < 7.0
30+
- Elasticsearch >= 7.0 < 8.0
3131

3232
.. _Search: http://elasticsearch-dsl.readthedocs.io/en/stable/search_dsl.html
3333

@@ -38,8 +38,8 @@ Install Django Elasticsearch DSL::
3838

3939
pip install django-elasticsearch-dsl
4040

41-
# Elasticsearch 6.x
42-
pip install 'elasticsearch-dsl>=6.3.0,<7.0'
41+
# Elasticsearch 7.x
42+
pip install 'elasticsearch-dsl>=7.0.0,<8.0.0'
4343

4444

4545
Then add ``django_elasticsearch_dsl`` to the INSTALLED_APPS

django_elasticsearch_dsl/documents.py

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def _prepare_action(self, object_instance, action):
132132
return {
133133
'_op_type': action,
134134
'_index': self._index._name,
135-
'_type': self._doc_type.name,
136135
'_id': object_instance.pk,
137136
'_source': (
138137
self.prepare(object_instance) if action != 'delete' else None

django_elasticsearch_dsl/indices.py

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ def document(self, document):
2222
registry.register_document(document)
2323
return document
2424

25-
doc_type = document
26-
2725
def __str__(self):
2826
return self._name

django_elasticsearch_dsl/test/testcases.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def setUp(self):
1010
doc._index._name += self._index_suffixe
1111

1212
for index in registry.get_indices():
13-
index._name += self._index_suffixe
13+
if not index._name.endswith(self._index_suffixe):
14+
index._name += self._index_suffixe
1415
index.delete(ignore=[404, 400])
1516
index.create()
1617

@@ -19,11 +20,11 @@ def setUp(self):
1920
def tearDown(self):
2021
pattern = re.compile(self._index_suffixe + '$')
2122

22-
for doc in registry.get_documents():
23-
doc._index._name = pattern.sub('', doc._index._name)
24-
2523
for index in registry.get_indices():
2624
index.delete(ignore=[404, 400])
2725
index._name = pattern.sub('', index._name)
2826

27+
for doc in registry.get_documents():
28+
doc._index._name = pattern.sub('', doc._index._name)
29+
2930
super(ESTestCase, self).tearDown()

example/test_app/documents.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
@car.doc_type
22+
@car.document
2323
class CarDocument(DocType):
2424
manufacturer = fields.ObjectField(properties={
2525
'name': fields.TextField(),
@@ -59,7 +59,7 @@ def get_instances_from_related(self, related_instance):
5959
return related_instance.car_set.all()
6060

6161

62-
@car.doc_type
62+
@car.document
6363
class ManufacturerDocument(DocType):
6464
country = fields.TextField()
6565

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
django>=1.9.6
2-
elasticsearch-dsl>=2.1.0,<6.2.0
2+
elasticsearch-dsl>=7.0.0,<8.0.0

requirements_dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bumpversion==0.5.3
22
wheel==0.32.2
33
django>=2.0,<2.2
4-
elasticsearch-dsl>=2.1.0,<6.2.0
4+
elasticsearch-dsl>=7.0.0,<8.0.0
55
twine
66
wheel==0.29.0
77
django>=2.0,<2.1

requirements_test.txt

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ Pillow==4.2.1
66

77

88
# Additional test requirements go here
9-
https://github.com/safwanrahman/elasticsearch-dsl-py/archive/document_method.tar.gz#egg=elasticsearch-dsl-py==6.3.3

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
],
4343
include_package_data=True,
4444
install_requires=[
45-
'elasticsearch-dsl>=6.3.0',
45+
'elasticsearch-dsl>=7.0.0,<8.0.0',
4646
],
4747
license="Apache Software License 2.0",
4848
zip_safe=False,

tests/documents.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
html_strip = analyzer(
1414
'html_strip',
1515
tokenizer="standard",
16-
filter=["standard", "lowercase", "stop", "snowball"],
16+
filter=["lowercase", "stop", "snowball"],
1717
char_filter=["html_strip"]
1818
)
1919

tests/test_documents.py

+13-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.db import models
44
from django.utils.translation import ugettext_lazy as _
5-
from elasticsearch_dsl import GeoPoint, MetaField
5+
from elasticsearch_dsl import GeoPoint
66
from mock import patch
77

88
from django_elasticsearch_dsl import fields
@@ -43,17 +43,13 @@ class CarDocument(DocType):
4343
def prepare_color(self, instance):
4444
return "blue"
4545

46-
class Meta:
47-
doc_type = 'car_document'
48-
4946
class Django:
5047
fields = ['name', 'price']
5148
model = Car
5249
related_models = [Manufacturer]
5350

5451
class Index:
5552
name = 'car_index'
56-
doc_type = 'car_document'
5753

5854

5955
class DocTypeTestCase(TestCase):
@@ -134,20 +130,18 @@ def test_mapping(self):
134130

135131
self.assertEqual(
136132
CarDocument._doc_type.mapping.to_dict(), {
137-
'car_document': {
138-
'properties': {
139-
'name': {
140-
'type': text_type
141-
},
142-
'color': {
143-
'type': text_type
144-
},
145-
'type': {
146-
'type': text_type
147-
},
148-
'price': {
149-
'type': 'double'
150-
}
133+
'properties': {
134+
'name': {
135+
'type': text_type
136+
},
137+
'color': {
138+
'type': text_type
139+
},
140+
'type': {
141+
'type': text_type
142+
},
143+
'price': {
144+
'type': 'double'
151145
}
152146
}
153147
}
@@ -209,7 +203,6 @@ def test_model_instance_update(self):
209203
'color': doc.prepare_color(None),
210204
},
211205
'_index': 'car_index',
212-
'_type': 'car_document'
213206
}]
214207
self.assertEqual(1, mock.call_count)
215208
self.assertEqual(
@@ -238,7 +231,6 @@ def test_model_instance_iterable_update(self):
238231
'color': doc.prepare_color(None),
239232
},
240233
'_index': 'car_index',
241-
'_type': 'car_document'
242234
},
243235
{
244236
'_id': car2.pk,
@@ -250,7 +242,6 @@ def test_model_instance_iterable_update(self):
250242
'color': doc.prepare_color(None),
251243
},
252244
'_index': 'car_index',
253-
'_type': 'car_document'
254245
}]
255246
self.assertEqual(1, mock.call_count)
256247
self.assertEqual(

tests/test_integration.py

+28-30
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_index_to_dict(self):
182182
text_type = 'string' if ES_MAJOR_VERSION == 2 else 'text'
183183

184184
test_index = DSLIndex('test_index').settings(**index_settings)
185-
test_index.doc_type(CarDocument)
185+
test_index.document(CarDocument)
186186

187187
index_dict = test_index.to_dict()
188188

@@ -193,7 +193,7 @@ def test_index_to_dict(self):
193193
'analyzer': {
194194
'html_strip': {
195195
'tokenizer': 'standard',
196-
'filter': ['standard', 'lowercase',
196+
'filter': ['lowercase',
197197
'stop', 'snowball'],
198198
'type': 'custom',
199199
'char_filter': ['html_strip']
@@ -202,38 +202,36 @@ def test_index_to_dict(self):
202202
}
203203
})
204204
self.assertEqual(index_dict['mappings'], {
205-
'doc': {
206-
'properties': {
207-
'ads': {
208-
'type': 'nested',
209-
'properties': {
210-
'description': {
211-
'type': text_type, 'analyzer':
212-
'html_strip'
213-
},
214-
'pk': {'type': 'integer'},
215-
'title': {'type': text_type}
205+
'properties': {
206+
'ads': {
207+
'type': 'nested',
208+
'properties': {
209+
'description': {
210+
'type': text_type, 'analyzer':
211+
'html_strip'
216212
},
213+
'pk': {'type': 'integer'},
214+
'title': {'type': text_type}
217215
},
218-
'categories': {
219-
'type': 'nested',
220-
'properties': {
221-
'title': {'type': text_type},
222-
'slug': {'type': text_type},
223-
'icon': {'type': text_type}
224-
},
216+
},
217+
'categories': {
218+
'type': 'nested',
219+
'properties': {
220+
'title': {'type': text_type},
221+
'slug': {'type': text_type},
222+
'icon': {'type': text_type}
225223
},
226-
'manufacturer': {
227-
'type': 'object',
228-
'properties': {
229-
'country': {'type': text_type},
230-
'name': {'type': text_type}
231-
},
224+
},
225+
'manufacturer': {
226+
'type': 'object',
227+
'properties': {
228+
'country': {'type': text_type},
229+
'name': {'type': text_type}
232230
},
233-
'name': {'type': text_type},
234-
'launched': {'type': 'date'},
235-
'type': {'type': text_type}
236-
}
231+
},
232+
'name': {'type': text_type},
233+
'launched': {'type': 'date'},
234+
'type': {'type': text_type}
237235
}
238236
})
239237

tox.ini

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[tox]
22
envlist =
3-
{py27,py36,py37}-django-110-{es6}
4-
{py27,py36,py37}-django-111-{es6}
5-
{py36,py37}-django-2-{es6}
6-
{py36,py37}-django-21-{es6}
3+
{py27,py36,py37}-django-110-{es7}
4+
{py27,py36,py37}-django-111-{es7}
5+
{py36,py37}-django-2-{es7}
6+
{py36,py37}-django-21-{es7}
77

88
[testenv]
99
setenv =
@@ -16,7 +16,7 @@ deps =
1616
django-111: Django>=1.11,<2.0
1717
django-2: Django>=2.0,<2.1
1818
django-21: Django>=2.1,<2.2
19-
es6: https://github.com/safwanrahman/elasticsearch-dsl-py/archive/document_method.tar.gz#egg=elasticsearch-dsl-py==6.3.3
19+
es7: elasticsearch-dsl>=7.0.0,<8.0.0
2020
-r{toxinidir}/requirements_test.txt
2121

2222
basepython =

0 commit comments

Comments
 (0)