Kaynağa Gözat

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.
Karl Hobley 7 yıl önce
ebeveyn
işleme
0d7faef513

+ 3 - 0
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'
 

+ 2 - 2
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