@manager.command
def index(foreign_id=None):
    """Index documents in the given source (or throughout)."""
    q = Document.all_ids()
    if foreign_id:
        source = Source.by_foreign_id(foreign_id)
        if source is None:
            raise ValueError("No such source: %r" % foreign_id)
        q = q.filter(Document.source_id == source.id)
    else:
        delete_index()
        init_search()
        indexentities()
    for doc_id, in q:
        index_document.delay(doc_id)
dataset/ETHPy150Open pudo/aleph/aleph/manage.py/index/original