コード例 #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
ファイル: entities.py プロジェクト: fork-for-review/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,
             '_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()