code: def test_extend_filtered():
      schema = fields.Schema(
          id=fields.STORED, text=fields.TEXT(stored=True)
      )
      ix = RamStorage().create_index(schema)
      w = ix.writer()
      w.add_document(id=1, text=u("alfa bravo charlie"))
      w.add_document(id=2, text=u("bravo charlie delta"))
      w.add_document(id=3, text=u("juliet delta echo"))
      w.add_document(id=4, text=u("delta bravo alfa"))
      w.add_document(id=5, text=u("foxtrot sierra tango"))
      w.commit()
  
      hits = lambda result: [hit["id"] for hit in result]
  
      with ix.searcher() as s:
          r1 = s.search(
              query.Term("text", u("alfa")), filter=set([1, 4])
          )
          assert r1.allowed == set([1, 4])
          assert len(r1.top_n) == 0
  
          r2 = s.search(query.Term("text", u("bravo")))
          assert len(r2.top_n) == 3
          assert hits(r2) == [1, 2, 4]
  
          r3 = r1.copy()
          assert r3.allowed == set([1, 4])
          assert len(r3.top_n) == 0
          r3.extend(r2)
          assert len(r3.top_n) == 3
          assert hits(r3) == [1, 2, 4]
  
imports: from __future__ import with_statement
  import pytest
  from whoosh import analysis, fields, formats, highlight, qparser, query
  from whoosh.codec.whoosh3 import W3Codec
  from whoosh.compat import u, xrange, text_type, permutations
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempStorage, TempIndex
label_desc: Use image node_id 8 for calling a global function with example usage: test_extend_filtered() without return types