'Empties an index, but doesn\'t delete it. Useful for tearDowns.
ids -- list of IDs to unindex.
_all -- unindex all objects.'

@classmethod
@task
def unindexer(cls, ids=None, _all=False, index=None):

    if _all:
        qs = cls.get_model()
        if hasattr(qs, 'with_deleted'):
            qs = qs.with_deleted
        else:
            qs = qs.objects
        ids = list(qs.order_by('id').values_list('id', flat=True))
    if (not ids):
        return
    log.info(('Unindexing    %s    %s-%s.    [%s]' % (cls.get_model()._meta.model_name, ids[0], ids[(-1)], len(ids))))
    index = (index or cls.get_index())
    indices = Reindexing.get_indices(index)
    es = cls.get_es(urls=settings.ES_URLS)
    for id_ in ids:
        for idx in indices:
            try:
                cls.unindex(id_=id_, es=es, index=idx)
            except elasticsearch.exceptions.NotFoundError:
                log.info((u'[%s:%s]    object    not    found    in    index' % (cls.get_model()._meta.model_name, id_)))
