code: def test_update2():
      schema = fields.Schema(
          key=fields.ID(unique=True, stored=True),
          p=fields.ID(stored=True),
      )
      with TempIndex(schema, "update2") as ix:
          nums = list(range(21))
          random.shuffle(nums)
          for i, n in enumerate(nums):
              w = ix.writer()
              w.update_document(key=text_type(n % 10), p=text_type(i))
              w.commit()
  
          with ix.searcher() as s:
              results = [d["key"] for _, d in s.iter_docs()]
              results = " ".join(sorted(results))
              assert results == "0 1 2 3 4 5 6 7 8 9"
  
imports: from __future__ import with_statement
  import random
  from collections import defaultdict
  from datetime import datetime
  import pytest
  from whoosh import analysis, fields, index, qparser, query, __version__
  from whoosh.compat import b, u, xrange, text_type, permutations
  from whoosh.filedb.filestore import RamStorage
  from whoosh.writing import IndexingError
  from whoosh.util.numeric import length_to_byte, byte_to_length
  from whoosh.util.testing import TempIndex, TempStorage
label_desc: Use image node_id 15 for calling a global function with example usage: test_update2() without return types