@wrap_exceptions<EOL><INDENT>def update(self, document_id, update_spec, namespace, timestamp):<DEDENT>
<EOL>self.commit()<EOL>document_id = '<STR_LIT>'.join(map(<EOL>lambda c: '<STR_LIT:\\>' + c if c in ESCAPE_CHARACTERS else c,<EOL>u(document_id)<EOL>))<EOL>query = "<STR_LIT>" % (self.unique_key, document_id)<EOL>results = self.solr.search(query)<EOL>if not len(results):<EOL><INDENT>self.commit()<EOL>results = self.solr.search(query)<EOL><DEDENT>for doc in results:<EOL><INDENT>doc.pop('<STR_LIT>')<EOL>doc.pop('<STR_LIT>')<EOL>updated = self.apply_update(doc, update_spec)<EOL>updated['<STR_LIT>'] = <NUM_LIT:0><EOL>self.upsert(updated, namespace, timestamp)<EOL>return updated<EOL><DEDENT>
Apply updates given in update_spec to the document whose id
        matches that of doc.