From 0d7faef51353e4b8f967768e33cac89211d68862 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 14 Dec 2017 15:16:31 +0000 Subject: [PATCH] Removed root content type name from document ids This hasn't been required since we separated indices per root content type for Elasticsearch 2 support. --- wagtail/search/backends/elasticsearch6.py | 3 +++ wagtail/search/tests/test_elasticsearch6_backend.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wagtail/search/backends/elasticsearch6.py b/wagtail/search/backends/elasticsearch6.py index cc1c38d410..3999b5aa8f 100644 --- a/wagtail/search/backends/elasticsearch6.py +++ b/wagtail/search/backends/elasticsearch6.py @@ -7,6 +7,9 @@ class Elasticsearch6Mapping(Elasticsearch5Mapping): all_field_name = '_all_text' edgengrams_field_name = '_edgengrams' + def get_document_id(self, obj): + return str(obj.pk) + def get_document_type(self): return 'doc' diff --git a/wagtail/search/tests/test_elasticsearch6_backend.py b/wagtail/search/tests/test_elasticsearch6_backend.py index 4f067d9c1b..58c8490471 100644 --- a/wagtail/search/tests/test_elasticsearch6_backend.py +++ b/wagtail/search/tests/test_elasticsearch6_backend.py @@ -547,7 +547,7 @@ class TestElasticsearch6Mapping(TestCase): self.assertDictEqual(mapping, expected_result) def test_get_document_id(self): - self.assertEqual(self.es_mapping.get_document_id(self.obj), 'searchtests_book:' + str(self.obj.pk)) + self.assertEqual(self.es_mapping.get_document_id(self.obj), str(self.obj.pk)) def test_get_document(self): # Get document @@ -652,7 +652,7 @@ class TestElasticsearch6MappingInheritance(TestCase): # This must be tests_searchtest instead of 'tests_searchtest_tests_searchtestchild' # as it uses the contents base content type name. # This prevents the same object being accidentally indexed twice. - self.assertEqual(self.es_mapping.get_document_id(self.obj), 'searchtests_book:' + str(self.obj.pk)) + self.assertEqual(self.es_mapping.get_document_id(self.obj), str(self.obj.pk)) def test_get_document(self): # Build document