From 83d4b4f9af2320381d2a924d84bc71e21c4fd1c8 Mon Sep 17 00:00:00 2001 From: Safwan Rahman Date: Mon, 3 Jun 2019 07:01:09 +0600 Subject: [PATCH 1/6] Support Elasticsearch 7.x --- .travis.yml | 2 +- requirements.txt | 3 ++- requirements_dev.txt | 2 +- setup.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f9e68b2..45090c7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/requirements.txt b/requirements.txt index dbaef8d6..cb1678c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ django>=1.9.6 -elasticsearch-dsl>=6.4.0,<7.0.0 +elasticsearch-dsl>=7.0.0,<8.0.0 + diff --git a/requirements_dev.txt b/requirements_dev.txt index 41164ffe..f65e3048 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -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 diff --git a/setup.py b/setup.py index cf327148..ddcace58 100755 --- a/setup.py +++ b/setup.py @@ -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, From 1717a0e10c754f4d4128522d1045363df39fcda2 Mon Sep 17 00:00:00 2001 From: Safwan Rahman Date: Mon, 3 Jun 2019 07:08:09 +0600 Subject: [PATCH 2/6] Support Elasticsearch 7.x --- django_elasticsearch_dsl/documents.py | 1 - 1 file changed, 1 deletion(-) diff --git a/django_elasticsearch_dsl/documents.py b/django_elasticsearch_dsl/documents.py index 4ee55ce8..ec4207e0 100644 --- a/django_elasticsearch_dsl/documents.py +++ b/django_elasticsearch_dsl/documents.py @@ -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 From c76af266da40e08b9fe8f8050346ae01712e4c4e Mon Sep 17 00:00:00 2001 From: Safwan Rahman Date: Mon, 3 Jun 2019 07:15:28 +0600 Subject: [PATCH 3/6] remove standard token filter --- README.rst | 2 +- example/test_app/documents.py | 2 +- tests/documents.py | 2 +- tests/test_integration.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 9bd35866..09de088f 100644 --- a/README.rst +++ b/README.rst @@ -354,7 +354,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"] ) diff --git a/example/test_app/documents.py b/example/test_app/documents.py index 05ffe5d8..1e7e1dfe 100644 --- a/example/test_app/documents.py +++ b/example/test_app/documents.py @@ -14,7 +14,7 @@ html_strip = analyzer( 'html_strip', tokenizer="standard", - filter=["standard", "lowercase", "stop", "snowball"], + filter=["lowercase", "stop", "snowball"], char_filter=["html_strip"] ) diff --git a/tests/documents.py b/tests/documents.py index e1451239..04e0ebfb 100644 --- a/tests/documents.py +++ b/tests/documents.py @@ -13,7 +13,7 @@ html_strip = analyzer( 'html_strip', tokenizer="standard", - filter=["standard", "lowercase", "stop", "snowball"], + filter=["lowercase", "stop", "snowball"], char_filter=["html_strip"] ) diff --git a/tests/test_integration.py b/tests/test_integration.py index 26960b49..ea60a4b2 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -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'] From d075f48d17a0f3b0ac66da037977ee135f426e45 Mon Sep 17 00:00:00 2001 From: Safwan Rahman Date: Mon, 3 Jun 2019 07:25:13 +0600 Subject: [PATCH 4/6] fix test --- tests/test_documents.py | 6 +----- tests/test_integration.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_documents.py b/tests/test_documents.py index d302d7b9..bea530cd 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -134,7 +134,6 @@ def test_mapping(self): self.assertEqual( CarDocument._doc_type.mapping.to_dict(), { - 'car_document': { 'properties': { 'name': { 'type': text_type @@ -149,7 +148,6 @@ def test_mapping(self): 'type': 'double' } } - } } ) @@ -238,7 +236,6 @@ def test_model_instance_iterable_update(self): 'color': doc.prepare_color(None), }, '_index': 'car_index', - '_type': 'car_document' }, { '_id': car2.pk, @@ -249,8 +246,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( diff --git a/tests/test_integration.py b/tests/test_integration.py index ea60a4b2..f8c4707f 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -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() From b9b061b2b3c0eb5c617c7775b18cd681cdf57b3e Mon Sep 17 00:00:00 2001 From: Safwan Rahman Date: Mon, 3 Jun 2019 07:29:53 +0600 Subject: [PATCH 5/6] fix test --- tests/test_documents.py | 1 - tests/test_integration.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/tests/test_documents.py b/tests/test_documents.py index bea530cd..d6e4e618 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -207,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( diff --git a/tests/test_integration.py b/tests/test_integration.py index f8c4707f..2d65cf52 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -202,7 +202,6 @@ def test_index_to_dict(self): } }) self.assertEqual(index_dict['mappings'], { - 'doc': { 'properties': { 'ads': { 'type': 'nested', @@ -234,7 +233,6 @@ def test_index_to_dict(self): 'launched': {'type': 'date'}, 'type': {'type': text_type} } - } }) def test_related_docs_are_updated(self): From 1f78ee48b9f7816afe1dca0a0ce4c94845d7f4e2 Mon Sep 17 00:00:00 2001 From: Safwan Rahman Date: Sun, 11 Aug 2019 02:05:45 +0600 Subject: [PATCH 6/6] Fixing documentation --- README.rst | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 09de088f..cc359d4d 100644 --- a/README.rst +++ b/README.rst @@ -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