예제 #1
0
파일: admin.py 프로젝트: B-Rich/fjord
def handle_reindex(request):
    """Caculate chunks and kick off indexing tasks."""
    index = get_index()

    batch_id = create_batch_id()

    # Break up all the things we want to index into chunks. This
    # chunkifies by class then by chunk size.
    chunks = []
    for cls, indexable in get_indexable():
        chunks.extend(
            (cls, chunk) for chunk in chunked(indexable, CHUNK_SIZE))

    # The previous lines do a lot of work and take some time to
    # execute.  So we wait until here to wipe and rebuild the
    # index. That reduces the time that there is no index by a little.
    recreate_index()

    for cls, id_list in chunks:
        chunk_name = '%s %d -> %d' % (cls.get_mapping_type_name(),
                                      id_list[0], id_list[-1])
        rec = Record(batch_id=batch_id, name=chunk_name)
        rec.save()
        index_chunk_task.delay(index, batch_id, rec.id,
                               (to_class_path(cls), id_list))

    return HttpResponseRedirect(request.path)
예제 #2
0
def handle_reindex(request):
    """Caculate chunks and kick off indexing tasks."""
    index = get_index()

    batch_id = create_batch_id()

    # Break up all the things we want to index into chunks. This
    # chunkifies by class then by chunk size.
    chunks = []
    for cls, indexable in get_indexable():
        chunks.extend((cls, chunk) for chunk in chunked(indexable, CHUNK_SIZE))

    # The previous lines do a lot of work and take some time to
    # execute.  So we wait until here to wipe and rebuild the
    # index. That reduces the time that there is no index by a little.
    recreate_index()

    for cls, id_list in chunks:
        chunk_name = '%s %d -> %d' % (cls.get_mapping_type_name(), id_list[0],
                                      id_list[-1])
        rec = Record(batch_id=batch_id, name=chunk_name)
        rec.save()
        index_chunk_task.delay(index, batch_id, rec.id, (cls, id_list))

    return HttpResponseRedirect(request.path)
예제 #3
0
파일: __init__.py 프로젝트: Givemore/fjord
    def setup_indexes(self, empty=False, wait=True):
        """(Re-)create ES indexes."""
        if empty:
            recreate_index()
        else:
            # Removes the index, creates a new one, and indexes
            # existing data into it.
            es_reindex_cmd()

        self.refresh()
        if wait:
            get_es().cluster.health(wait_for_status='yellow')
예제 #4
0
파일: __init__.py 프로젝트: xrile/fjord
    def setup_indexes(self, empty=False, wait=True):
        """(Re-)create ES indexes."""
        if empty:
            recreate_index()
        else:
            # Removes the index, creates a new one, and indexes
            # existing data into it.
            es_reindex_cmd()

        self.refresh()
        if wait:
            get_es().cluster.health(wait_for_status='yellow')
예제 #5
0
파일: admin.py 프로젝트: DerekRies/fjord
def handle_recreate_reindex(request):
    recreate_index()
    reindex()
    return HttpResponseRedirect(request.path)
예제 #6
0
파일: admin.py 프로젝트: xrile/fjord
def handle_recreate_reindex(request):
    recreate_index()
    reindex()
    return HttpResponseRedirect(request.path)