def test_recreate_index(self):
"""
django.core.exceptions.ImproperlyConfigured:
Model '<class 'tests.test_app.models.MockModel'>' has more than one 'SearchIndex`` handling it.
Please exclude either '<tests.test_app.search_indexes.ElasticsearchAutocompleteMockModelSearchIndex object at 0x10b7881c8>'
or
'<tests.test_app.search_indexes.ElasticsearchComplexFacetsMockSearchIndex object at 0x10b788228>'
using the 'EXCLUDED_INDEXES' setting defined in 'settings.HAYSTACK_CONNECTIONS'.
"""
clear_elasticsearch_index()
search_backend = connections['default'].get_backend()
search_backend.silently_fail = True
search_backend.setup()
original_mapping = self.raw_es.indices.get_mapping(index=search_backend.index_name)
search_backend.clear()
search_backend.setup()
try:
updated_mapping = self.raw_es.indices.get_mapping(search_backend.index_name)
except elasticsearch.NotFoundError:
self.fail("There is no mapping after recreating the index")
self.assertEqual(original_mapping, updated_mapping,
"Mapping after recreating the index differs from the original one")
评论列表
文章目录