code: def test_terms():
      schema = fields.Schema(text=fields.TEXT(stored=True))
      ix = RamStorage().create_index(schema)
      w = ix.writer()
      w.add_document(text=u("alfa sierra tango"))
      w.add_document(text=u("bravo charlie delta"))
      w.add_document(text=u("charlie delta echo"))
      w.add_document(text=u("delta echo foxtrot"))
      w.commit()
  
      qp = qparser.QueryParser("text", ix.schema)
      q = qp.parse(u("(bravo AND charlie) OR foxtrot OR missing"))
      r = ix.searcher().search(q, terms=True)
  
      fieldobj = schema["text"]
  
      def txts(tset):
          return sorted(fieldobj.from_bytes(t[1]) for t in tset)
  
      assert txts(r.matched_terms()) == ["bravo", "charlie", "foxtrot"]
      for hit in r:
          value = hit["text"]
          for txt in txts(hit.matched_terms()):
              assert txt in value
  
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 20 for calling a global function with example usage: test_terms() and returns: sorted