code: def test_reverse_collapse():
      from whoosh import sorting
  
      schema = fields.Schema(
          title=fields.TEXT(stored=True),
          content=fields.TEXT,
          path=fields.ID(stored=True),
          tags=fields.KEYWORD,
          order=fields.NUMERIC(stored=True),
      )
  
      ix = RamStorage().create_index(schema)
      with ix.writer() as w:
          w.add_document(
              title="First document",
              content="This is my document!",
              path="/a",
              tags="first",
              order=20.0,
          )
          w.add_document(
              title="Second document",
              content="This is the second example.",
              path="/b",
              tags="second",
              order=12.0,
          )
          w.add_document(
              title="Third document",
              content="Examples are many.",
              path="/c",
              tags="third",
              order=15.0,
          )
          w.add_document(
              title="Thirdish document",
              content="Examples are too many.",
              path="/d",
              tags="third",
              order=25.0,
          )
  
      with ix.searcher() as s:
          q = query.Every("content")
          r = s.search(q)
          assert [hit["path"] for hit in r] == ["/a", "/b", "/c", "/d"]
  
          q = query.Or(
              [
                  query.Term("title", "document"),
                  query.Term("content", "document"),
                  query.Term("tags", "document"),
              ]
          )
          cf = sorting.FieldFacet("tags")
          of = sorting.FieldFacet("order", reverse=True)
          r = s.search(q, collapse=cf, collapse_order=of, terms=True)
          assert [hit["path"] for hit in r] == ["/a", "/b", "/d"]
  
file_path: whoosh/tests/test_collector.py
imports: from __future__ import with_statement
  import pytest
  from whoosh import collectors, fields, query, searching
  from whoosh.compat import u, xrange
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempIndex
label_desc: Use image node_id 5 for calling a global function with example usage: test_reverse_collapse() without return types