code: def test_boolean_find_deleted():
      # "Random" string of ones and zeros representing deleted and undeleted
      domain = "1110001010001110010101000101001011101010001011111101000101010101"
  
      schema = fields.Schema(
          i=fields.STORED, b=fields.BOOLEAN(stored=True)
      )
      ix = RamStorage().create_index(schema)
      count = 0
      # Create multiple segments just in case
      for _ in xrange(5):
          w = ix.writer()
          for c in domain:
              w.add_document(i=count, b=(c == "1"))
          w.commit(merge=False)
  
      # Delete documents where "b" is True
      with ix.writer() as w:
          w.delete_by_term("b", "t")
  
      with ix.searcher() as s:
          # Double check that documents with b=True are all deleted
          reader = s.reader()
          for docnum in xrange(s.doc_count_all()):
              b = s.stored_fields(docnum)["b"]
              assert b == reader.is_deleted(docnum)
  
          # Try doing a search for documents where b=True
          qp = qparser.QueryParser("b", ix.schema)
          q = qp.parse("b:t")
          r = s.search(q, limit=None)
          assert len(r) == 0
  
          # Make sure Every query doesn't match deleted docs
          r = s.search(qp.parse("*"), limit=None)
          assert not any(hit["b"] for hit in r)
          assert not any(reader.is_deleted(hit.docnum) for hit in r)
  
          r = s.search(qp.parse("*:*"), limit=None)
          assert not any(hit["b"] for hit in r)
          assert not any(reader.is_deleted(hit.docnum) for hit in r)
  
          # Make sure Not query doesn't match deleted docs
          q = qp.parse("NOT b:t")
          r = s.search(q, limit=None)
          assert not any(hit["b"] for hit in r)
          assert not any(reader.is_deleted(hit.docnum) for hit in r)
  
          r = s.search(q, limit=5)
          assert not any(hit["b"] for hit in r)
          assert not any(reader.is_deleted(hit.docnum) for hit in r)
  
imports: from __future__ import with_statement
  from datetime import datetime, timedelta
  import pytest
  from whoosh import fields, qparser, query
  from whoosh.compat import u, b, xrange
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util import times
  from whoosh.util.testing import TempIndex
label_desc: Use image node_id 22 for calling a global function with example usage: test_boolean_find_deleted() without return types