Skip to content

Commit 5e479bd

Browse files
authored
Merge pull request #176 from safwanrahman/es_7
[Fix #170] Support Elasticsearch 7.x
2 parents 51db109 + 1f78ee4 commit 5e479bd

File tree

10 files changed

+31
-19
lines changed

10 files changed

+31
-19
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ matrix:
3131
cache: pip
3232
env:
3333
global:
34-
- ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
34+
- ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
3535

3636
before_install:
3737
# work around https://github.com/travis-ci/travis-ci/issues/8363

README.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,26 @@ Features
2727

2828
- Django >= 1.10
2929
- Python 2.7, 3.5, 3.6, 3.7
30-
- Elasticsearch >= 6.0 < 7.0
30+
31+
**Elasticsearch Compatibility:**
32+
The library is compatible with all Elasticsearch versions since 5.x **but you have to use a matching major version:**
33+
34+
- For Elasticsearch 7.0 and later, use the major version 7 (7.x.y) of the library.
35+
36+
- For Elasticsearch 6.0 and later, use the major version 6 (6.x.y) of the library.
37+
38+
- For Elasticsearch 5.0 and later, use the major version 0.5 (0.5.x) of the library.
39+
40+
.. code-block:: python
41+
42+
# Elasticsearch 7.x
43+
elasticsearch-dsl>=7.0.0,<8.0.0
44+
45+
# Elasticsearch 6.x
46+
elasticsearch-dsl>=6.0.0,<7.0.0
47+
48+
# Elasticsearch 5.x
49+
elasticsearch-dsl>=0.5.1,<6.0.0
3150
3251
.. _Search: http://elasticsearch-dsl.readthedocs.io/en/stable/search_dsl.html
3352

@@ -354,7 +373,7 @@ So for example you can use a custom analyzer_:
354373
html_strip = analyzer(
355374
'html_strip',
356375
tokenizer="standard",
357-
filter=["standard", "lowercase", "stop", "snowball"],
376+
filter=["lowercase", "stop", "snowball"],
358377
char_filter=["html_strip"]
359378
)
360379

django_elasticsearch_dsl/documents.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def _prepare_action(self, object_instance, action):
127127
return {
128128
'_op_type': action,
129129
'_index': self._index._name,
130-
'_type': self._doc_type.name,
131130
'_id': object_instance.pk,
132131
'_source': (
133132
self.prepare(object_instance) if action != 'delete' else None

example/test_app/documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
html_strip = analyzer(
1515
'html_strip',
1616
tokenizer="standard",
17-
filter=["standard", "lowercase", "stop", "snowball"],
17+
filter=["lowercase", "stop", "snowball"],
1818
char_filter=["html_strip"]
1919
)
2020

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
django>=1.9.6
2-
elasticsearch-dsl>=6.4.0,<7.0.0
2+
elasticsearch-dsl>=7.0.0,<8.0.0
3+

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
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

setup.py

Lines changed: 1 addition & 1 deletion
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.4.0,<7.0.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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def test_mapping(self):
134134

135135
self.assertEqual(
136136
CarDocument._doc_type.mapping.to_dict(), {
137-
'car_document': {
138137
'properties': {
139138
'name': {
140139
'type': text_type
@@ -149,7 +148,6 @@ def test_mapping(self):
149148
'type': 'double'
150149
}
151150
}
152-
}
153151
}
154152
)
155153

@@ -209,7 +207,6 @@ def test_model_instance_update(self):
209207
'color': doc.prepare_color(None),
210208
},
211209
'_index': 'car_index',
212-
'_type': 'car_document'
213210
}]
214211
self.assertEqual(1, mock.call_count)
215212
self.assertEqual(
@@ -238,7 +235,6 @@ def test_model_instance_iterable_update(self):
238235
'color': doc.prepare_color(None),
239236
},
240237
'_index': 'car_index',
241-
'_type': 'car_document'
242238
},
243239
{
244240
'_id': car2.pk,
@@ -249,8 +245,7 @@ def test_model_instance_iterable_update(self):
249245
'type': car2.type(),
250246
'color': doc.prepare_color(None),
251247
},
252-
'_index': 'car_index',
253-
'_type': 'car_document'
248+
'_index': 'car_index'
254249
}]
255250
self.assertEqual(1, mock.call_count)
256251
self.assertEqual(

tests/test_integration.py

Lines changed: 2 additions & 4 deletions
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,7 +202,6 @@ def test_index_to_dict(self):
202202
}
203203
})
204204
self.assertEqual(index_dict['mappings'], {
205-
'doc': {
206205
'properties': {
207206
'ads': {
208207
'type': 'nested',
@@ -234,7 +233,6 @@ def test_index_to_dict(self):
234233
'launched': {'type': 'date'},
235234
'type': {'type': text_type}
236235
}
237-
}
238236
})
239237

240238
def test_related_docs_are_updated(self):

0 commit comments

Comments
 (0)