code: def test_query_facet():
      schema = fields.Schema(id=fields.STORED, v=fields.ID)
      ix = RamStorage().create_index(schema)
      for i, ltr in enumerate(u("iacgbehdf")):
          w = ix.writer()
          w.add_document(id=i, v=ltr)
          w.commit(merge=False)
  
      with ix.searcher() as s:
          q1 = query.TermRange("v", "a", "c")
          q2 = query.TermRange("v", "d", "f")
          q3 = query.TermRange("v", "g", "i")
  
          assert [hit["id"] for hit in s.search(q1)] == [1, 2, 4]
          assert [hit["id"] for hit in s.search(q2)] == [5, 7, 8]
          assert [hit["id"] for hit in s.search(q3)] == [0, 3, 6]
  
          facet = sorting.QueryFacet({"a-c": q1, "d-f": q2, "g-i": q3})
          r = s.search(query.Every(), groupedby=facet)
          # If you specify a facet without a name, it's automatically called
          # "facet"
          assert r.groups("facet") == {
              "a-c": [1, 2, 4],
              "d-f": [5, 7, 8],
              "g-i": [0, 3, 6],
          }
  
imports: from __future__ import with_statement
  from datetime import datetime, timedelta
  import random
  from whoosh import fields, query, sorting, columns
  from whoosh.compat import u
  from whoosh.compat import permutations, xrange
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempIndex
label_desc: Use image node_id 13 for calling a global function with example usage: test_query_facet() without return types