code: def test_deletion():
      s = fields.Schema(
          key=fields.ID, name=fields.TEXT, value=fields.TEXT
      )
      with TempIndex(s, "deletion") as ix:
          w = ix.writer()
          w.add_document(
              key=u("A"),
              name=u("Yellow brown"),
              value=u("Blue red green purple?"),
          )
          w.add_document(
              key=u("B"),
              name=u("Alpha beta"),
              value=u("Gamma delta epsilon omega."),
          )
          w.add_document(
              key=u("C"), name=u("One two"), value=u("Three four five.")
          )
          w.commit()
  
          w = ix.writer()
          assert w.delete_by_term("key", u("B")) == 1
          w.commit(merge=False)
  
          assert ix.doc_count_all() == 3
          assert ix.doc_count() == 2
  
          w = ix.writer()
          w.add_document(
              key=u("A"),
              name=u("Yellow brown"),
              value=u("Blue red green purple?"),
          )
          w.add_document(
              key=u("B"),
              name=u("Alpha beta"),
              value=u("Gamma delta epsilon omega."),
          )
          w.add_document(
              key=u("C"), name=u("One two"), value=u("Three four five.")
          )
          w.commit()
  
          # This will match both documents with key == B, one of which is already
          # deleted. This should not raise an error.
          w = ix.writer()
          assert w.delete_by_term("key", u("B")) == 1
          w.commit()
  
          ix.optimize()
          assert ix.doc_count_all() == 4
          assert ix.doc_count() == 4
  
          with ix.reader() as tr:
              assert (
                  " ".join(tr.field_terms("name"))
                  == "brown one two yellow"
              )
  
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 12 for calling a global function with example usage: test_deletion() without return types