def update(self, *args, **kwargs):
if args:<EOL><INDENT>for arg in args:<EOL><INDENT>if not isinstance(arg, ScriptField):<EOL><INDENT>raise InvalidParameter("<STR_LIT>" % arg)<EOL><DEDENT><DEDENT><DEDENT>query = self._build_query()<EOL>connection = self.model._meta.dj_connection<EOL>query.fields = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]<EOL>conn = connection.connection<EOL>results = conn.search(query, indices=connection.database, doc_types=self.type, scan=True)<EOL>for item in results:<EOL><INDENT>if kwargs:<EOL><INDENT>conn.update(item._meta.index, item._meta.type, item._meta.id, document=kwargs, bulk=True)<EOL><DEDENT>for script in args:<EOL><INDENT>conn.update(item._meta.index, item._meta.type, item._meta.id,<EOL>script=script.script, lang=script.lang, params=script.params, bulk=True)<EOL><DEDENT><DEDENT>connection.connection.flush_bulk(True)<EOL>self._result_cache = None<EOL>
Updates all elements in the current QuerySet, setting all the given
fields to the appropriate values.