'Updates all elements in the current QuerySet, setting all the given
fields to the appropriate values.'

def update(self, *args, **kwargs):

    if args:
        for arg in args:
            if (not isinstance(arg, ScriptField)):
                raise InvalidParameter(('%s    this    must    be    a    ScriptField    or    derivated' % arg))
    query = self._build_query()
    connection = self.model._meta.dj_connection
    query.fields = ['_id', '_type', '_index']
    conn = connection.connection
    results = conn.search(query, indices=connection.database, doc_types=self.type, scan=True)
    for item in results:
        if kwargs:
            conn.update(item._meta.index, item._meta.type, item._meta.id, document=kwargs, bulk=True)
        for script in args:
            conn.update(item._meta.index, item._meta.type, item._meta.id, script=script.script, lang=script.lang, params=script.params, bulk=True)
    connection.connection.flush_bulk(True)
    self._result_cache = None
