예제 #1
0
파일: entities.py 프로젝트: pudo/aleph
 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)
예제 #2
0
 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)
예제 #3
0
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()
예제 #4
0
 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()