def setUp(self):
     data = [{
         'headline': 'test {}'.format(i),
         'slugline': 'rebuild {}'.format(i),
         'type': 'text' if (i % 2 == 0) else 'picture'
     } for i in range(11, 21)]
     get_resource_service('ingest').post(data)
     RebuildElasticIndex().run()
     sleep(1)  # sleep so Elastic has time to refresh the indexes
Пример #2
0
    def test_retrieve_items_after_index_rebuilt(self):
        RESOURCE = 'ingest'
        elastic = self.app.data.elastic
        alias = elastic._resource_index(RESOURCE)
        alias_info = elastic.elastic(RESOURCE).indices.get_alias(name=alias)

        data = [{
            'headline': 'test {}'.format(i),
            'slugline': 'rebuild {}'.format(i),
            'type': 'text' if (i % 2 == 0) else 'picture'
        } for i in range(11, 21)]
        get_resource_service(RESOURCE).post(data)
        RebuildElasticIndex().run()
        alias_info_new = elastic.elastic(RESOURCE).indices.get_alias(
            name=alias)
        self.assertNotEqual(alias_info, alias_info_new)

        req = ParsedRequest()
        req.args = {}
        req.max_results = 25
        items = get_resource_service('ingest').get(req, {})
        self.assertEqual(10, items.count())
Пример #3
0
def update_schema():
    """Run rebuild elastic index command to update schema."""
    RebuildElasticIndex().run()
 def forwards(self, mongodb_collection, mongodb_database):
     RebuildElasticIndex()()