test_backend.py 文件源码

python
阅读 74 收藏 0 点赞 0 评论 0

项目:haystack-elasticsearch5 作者: Alkalit 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号