def _generate(): for entity in Entity.by_collection(collection.id): entity_id, index, body = index_operation(entity.to_dict()) yield { '_id': entity_id, '_index': index, '_source': body } yield from generate_collection_docs(collection)
def _generate(): for entity in Entity.by_collection(collection.id): entity_id, index, body = index_operation(entity.to_dict()) yield { '_id': entity_id, '_index': index, '_type': 'doc', '_source': body } yield from generate_collection_docs(collection)
def aggregate_model(collection, aggregator): """Sync up the aggregator from the Aleph domain model.""" log.debug("[%s] Aggregating model...", collection) aggregator.delete(origin=MODEL_ORIGIN) writer = aggregator.bulk() for document in Document.by_collection(collection.id): proxy = document.to_proxy(ns=collection.ns) writer.put(proxy, fragment="db", origin=MODEL_ORIGIN) for entity in Entity.by_collection(collection.id): proxy = entity.to_proxy() aggregator.delete(entity_id=proxy.id) writer.put(proxy, fragment="db", origin=MODEL_ORIGIN) writer.flush()
def _proxies(collection): for entity in Entity.by_collection(collection.id).yield_per(5000): yield entity.to_proxy() for document in Document.by_collection(collection.id).yield_per(5000): yield document.to_proxy()