'Force an immediate refresh for the index(es) holding the given
doctype(s) in ES. Both a string corresponding to a single doctypes or a
list of multiple doctypes are accepted.
If there are tasks in the post_request_task queue, they are processed
first.'

@classmethod
def refresh(cls, doctypes=None):

    post_request_task._send_tasks_and_stop_queuing()
    if doctypes:
        if (not isinstance(doctypes, (list, tuple))):
            doctypes = [doctypes]
        indexes = [settings.ES_INDEXES[doctype] for doctype in doctypes]
        try:
            cls.es.indices.refresh(index=indexes)
        except elasticsearch.NotFoundError as e:
            print ("Could    not    refresh    indexes    '%s':    %s" % (indexes, e))
