def test_percolator(app, request): """Test percolator.""" def teardown(): with app.app_context(): current_collections.unregister_signals() list(current_search.delete()) request.addfinalizer(teardown) with app.test_request_context(): app.config.update( COLLECTIONS_USE_PERCOLATOR=True, SEARCH_ELASTIC_KEYWORD_MAPPING={None: ['_all']}, ) search = InvenioSearch(app) search.register_mappings('records', 'data') InvenioIndexer(app) current_collections.unregister_signals() current_collections.register_signals() list(current_search.create()) _try_populate_collections()
def migrate_chunk(chunk): models_committed.disconnect(receive_after_model_commit) current_collections.unregister_signals() index_queue = [] try: for raw_record in chunk: with db.session.begin_nested(): record = migrate_and_insert_record(raw_record) if record: index_queue.append(create_index_op(record)) db.session.commit() finally: db.session.close() req_timeout = current_app.config['INDEXER_BULK_REQUEST_TIMEOUT'] es_bulk( es, index_queue, stats_only=True, request_timeout=req_timeout, ) models_committed.connect(receive_after_model_commit) current_collections.register_signals()
def test_without_percolator(app, request): """Test percolator.""" with app.test_request_context(): app.config.update(COLLECTIONS_USE_PERCOLATOR=False, ) current_collections.unregister_signals() current_collections.register_signals() _try_populate_collections()
def test_without_percolator(app, request): """Test percolator.""" with app.test_request_context(): app.config.update( COLLECTIONS_USE_PERCOLATOR=False, ) current_collections.unregister_signals() current_collections.register_signals() _try_populate_collections()