Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #170] Support Elasticsearch 7.x #176

Merged
merged 6 commits into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ matrix:
cache: pip
env:
global:
- ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
- ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt

before_install:
# work around https://github.com/travis-ci/travis-ci/issues/8363
Expand Down
23 changes: 21 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,26 @@ Features

- Django >= 1.10
- Python 2.7, 3.5, 3.6, 3.7
- Elasticsearch >= 6.0 < 7.0

**Elasticsearch Compatibility:**
The library is compatible with all Elasticsearch versions since 5.x **but you have to use a matching major version:**

- For Elasticsearch 7.0 and later, use the major version 7 (7.x.y) of the library.

- For Elasticsearch 6.0 and later, use the major version 6 (6.x.y) of the library.

- For Elasticsearch 5.0 and later, use the major version 0.5 (0.5.x) of the library.

.. code-block:: python

# Elasticsearch 7.x
elasticsearch-dsl>=7.0.0,<8.0.0

# Elasticsearch 6.x
elasticsearch-dsl>=6.0.0,<7.0.0

# Elasticsearch 5.x
elasticsearch-dsl>=0.5.1,<6.0.0

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

Expand Down Expand Up @@ -354,7 +373,7 @@ So for example you can use a custom analyzer_:
html_strip = analyzer(
'html_strip',
tokenizer="standard",
filter=["standard", "lowercase", "stop", "snowball"],
filter=["lowercase", "stop", "snowball"],
char_filter=["html_strip"]
)

Expand Down
1 change: 0 additions & 1 deletion django_elasticsearch_dsl/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def _prepare_action(self, object_instance, action):
return {
'_op_type': action,
'_index': self._index._name,
'_type': self._doc_type.name,
'_id': object_instance.pk,
'_source': (
self.prepare(object_instance) if action != 'delete' else None
Expand Down
2 changes: 1 addition & 1 deletion example/test_app/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
html_strip = analyzer(
'html_strip',
tokenizer="standard",
filter=["standard", "lowercase", "stop", "snowball"],
filter=["lowercase", "stop", "snowball"],
char_filter=["html_strip"]
)

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
django>=1.9.6
elasticsearch-dsl>=6.4.0,<7.0.0
elasticsearch-dsl>=7.0.0,<8.0.0

2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bumpversion==0.5.3
wheel==0.32.2
django>=2.0,<2.2
elasticsearch-dsl>=2.1.0,<6.2.0
elasticsearch-dsl>=7.0.0,<8.0.0
twine
wheel==0.29.0
django>=2.0,<2.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
],
include_package_data=True,
install_requires=[
'elasticsearch-dsl>=6.4.0,<7.0.0',
'elasticsearch-dsl>=7.0.0<8.0.0',
],
license="Apache Software License 2.0",
zip_safe=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
html_strip = analyzer(
'html_strip',
tokenizer="standard",
filter=["standard", "lowercase", "stop", "snowball"],
filter=["lowercase", "stop", "snowball"],
char_filter=["html_strip"]
)

Expand Down
7 changes: 1 addition & 6 deletions tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def test_mapping(self):

self.assertEqual(
CarDocument._doc_type.mapping.to_dict(), {
'car_document': {
'properties': {
'name': {
'type': text_type
Expand All @@ -149,7 +148,6 @@ def test_mapping(self):
'type': 'double'
}
}
}
}
)

Expand Down Expand Up @@ -209,7 +207,6 @@ def test_model_instance_update(self):
'color': doc.prepare_color(None),
},
'_index': 'car_index',
'_type': 'car_document'
}]
self.assertEqual(1, mock.call_count)
self.assertEqual(
Expand Down Expand Up @@ -238,7 +235,6 @@ def test_model_instance_iterable_update(self):
'color': doc.prepare_color(None),
},
'_index': 'car_index',
'_type': 'car_document'
},
{
'_id': car2.pk,
Expand All @@ -249,8 +245,7 @@ def test_model_instance_iterable_update(self):
'type': car2.type(),
'color': doc.prepare_color(None),
},
'_index': 'car_index',
'_type': 'car_document'
'_index': 'car_index'
}]
self.assertEqual(1, mock.call_count)
self.assertEqual(
Expand Down
6 changes: 2 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_index_to_dict(self):
text_type = 'string' if ES_MAJOR_VERSION == 2 else 'text'

test_index = DSLIndex('test_index').settings(**index_settings)
test_index.doc_type(CarDocument)
test_index.document(CarDocument)

index_dict = test_index.to_dict()

Expand All @@ -193,7 +193,7 @@ def test_index_to_dict(self):
'analyzer': {
'html_strip': {
'tokenizer': 'standard',
'filter': ['standard', 'lowercase',
'filter': ['lowercase',
'stop', 'snowball'],
'type': 'custom',
'char_filter': ['html_strip']
Expand All @@ -202,7 +202,6 @@ def test_index_to_dict(self):
}
})
self.assertEqual(index_dict['mappings'], {
'doc': {
'properties': {
'ads': {
'type': 'nested',
Expand Down Expand Up @@ -234,7 +233,6 @@ def test_index_to_dict(self):
'launched': {'type': 'date'},
'type': {'type': text_type}
}
}
})

def test_related_docs_are_updated(self):
Expand Down