예제 #1
0
파일: conftest.py 프로젝트: etalab/cada
def clean_es(app):
    with app.test_request_context('/'):
        es.initialize()
        es.cluster.health(index=es.index_name, wait_for_status='yellow', request_timeout=1)
    yield
    with app.test_request_context('/'):
        es.indices.delete(index=es.index_name, ignore=[400, 404])
예제 #2
0
파일: commands.py 프로젝트: pborreli/cada
def reindex():
    '''Reindex all advices'''
    print('Deleting index {0}'.format(es.index_name))
    if es.indices.exists(es.index_name):
        es.indices.delete(index=es.index_name)
    es.initialize()

    for idx, advice in enumerate(Advice.objects, 1):
        topics = []
        for topic in advice.topics:
            topics.append(topic)
            parts = topic.split('/')
            if len(parts) > 1:
                topics.append(parts[0])
        es.index(index=es.index_name, doc_type=DOCTYPE, id=advice.id, body={
            'id': advice.id,
            'administration': advice.administration,
            'type': advice.type,
            'session': advice.session.strftime('%Y-%m-%d'),
            'subject': advice.subject,
            'topics': topics,
            'tags': advice.tags,
            'meanings': advice.meanings,
            'part': advice.part,
            'content': advice.content,
        })
        print('.' if idx % 50 else idx, end='')

    es.indices.refresh(index=es.index_name)
    print('\nIndexed {0} advices'.format(idx))
예제 #3
0
def clean_es(app):
    with app.test_request_context('/'):
        es.initialize()
        es.cluster.health(index=es.index_name,
                          wait_for_status='yellow',
                          request_timeout=1)
    yield
    with app.test_request_context('/'):
        es.indices.delete(index=es.index_name, ignore=[400, 404])
예제 #4
0
파일: commands.py 프로젝트: trojette/cada
def reindex():
    '''Reindex all advices'''
    print('Deleting index {0}'.format(es.index_name))
    if es.indices.exists(es.index_name):
        es.indices.delete(index=es.index_name)
    es.initialize()

    for idx, advice in enumerate(Advice.objects, 1):
        index(advice)
        print('.' if idx % 50 else idx, end='')

    es.indices.refresh(index=es.index_name)
    print('\nIndexed {0} advices'.format(idx))
예제 #5
0
def reindex():
    '''Reindex all advices'''
    print('Deleting index {0}'.format(es.index_name))
    if es.indices.exists(es.index_name):
        es.indices.delete(index=es.index_name)
    es.initialize()

    idx = 0
    for idx, advice in enumerate(Advice.objects, 1):
        index(advice)
        print('.' if idx % 50 else idx, end='')

    es.indices.refresh(index=es.index_name)
    print('\nIndexed {0} advices'.format(idx))
예제 #6
0
def reindex():
    '''Reindex all advices'''
    header('Reindexing all advices')
    echo('Deleting index {0}', white(es.index_name))
    if es.indices.exists(es.index_name):
        es.indices.delete(index=es.index_name)
    es.initialize()

    idx = 0
    for idx, advice in enumerate(Advice.objects, 1):
        index(advice)
        echo('.' if idx % 50 else white(idx), nl=False)
    echo(white(idx) if idx % 50 else '')
    es.indices.refresh(index=es.index_name)
    success('Indexed {0} advices', idx)
예제 #7
0
파일: commands.py 프로젝트: etalab/cada
def reindex():
    '''Reindex all advices'''
    header('Reindexing all advices')
    echo('Deleting index {0}', white(es.index_name))
    if es.indices.exists(es.index_name):
        es.indices.delete(index=es.index_name)
    es.initialize()

    idx = 0
    for idx, advice in enumerate(Advice.objects, 1):
        index(advice)
        echo('.' if idx % 50 else white(idx), nl=False)
    echo(white(idx) if idx % 50 else '')
    es.indices.refresh(index=es.index_name)
    success('Indexed {0} advices', idx)