class_docstr: A query that allows you to search for "nested" documents, where you can
  index (possibly multiple levels of) "parent" and "child" documents using
  the :meth:`~whoosh.writing.IndexWriter.group` and/or
  :meth:`~whoosh.writing.IndexWriter.start_group` methods of a
  :class:`whoosh.writing.IndexWriter` to indicate that hierarchically related
  documents should be kept together::
  
      schema = fields.Schema(type=fields.ID, text=fields.TEXT(stored=True))
  
      with ix.writer() as w:
          # Say we're indexing chapters (type=chap) and each chapter has a
          # number of paragraphs (type=p)
          with w.group():
              w.add_document(type="chap", text="Chapter 1")
              w.add_document(type="p", text="Able baker")
              w.add_document(type="p", text="Bright morning")
          with w.group():
              w.add_document(type="chap", text="Chapter 2")
              w.add_document(type="p", text="Car trip")
              w.add_document(type="p", text="Dog eared")
              w.add_document(type="p", text="Every day")
          with w.group():
              w.add_document(type="chap", text="Chapter 3")
              w.add_document(type="p", text="Fine day")
  
  The ``NestedParent`` query wraps two sub-queries: the "parent query"
  matches a class of "parent documents". The "sub query" matches nested
  documents you want to find. For each "sub document" the "sub query" finds,
  this query acts as if it found the corresponding "parent document".
  
  >>> with ix.searcher() as s:
  ...   r = s.search(query.Term("text", "day"))
  ...   for hit in r:
  ...     print(hit["text"])
  ...
  Chapter 2
  Chapter 3
class_docstr_tok: ["A","query","that","allows","you","to","search","for","``","nested","''","documents",",","where","you","can","index","(","possibly","multiple","levels","of",")","``","parent","''","and","``","child","''","documents","using","the",":","meth",":","`","~whoosh.writing.IndexWriter.group","`","and\/or",":","meth",":","`","~whoosh.writing.IndexWriter.start_group","`","methods","of","a",":","class",":","`","whoosh.writing.IndexWriter","`","to","indicate","that","hierarchically","related","documents","should","be","kept","together",":",":","schema","=","fields.Schema","(","type=fields.ID",",","text=fields.TEXT","(","stored=True",")",")","with","ix.writer","(",")","as","w",":","#","Say","we","'re","indexing","chapters","(","type=chap",")","and","each","chapter","has","a","#","number","of","paragraphs","(","type=p",")","with","w.group","(",")",":","w.add_document","(","type=","''","chap","''",",","text=","''","Chapter","1","''",")","w.add_document","(","type=","''","p","''",",","text=","''","Able","baker","''",")","w.add_document","(","type=","''","p","''",",","text=","''","Bright","morning","''",")","with","w.group","(",")",":","w.add_document","(","type=","''","chap","''",",","text=","''","Chapter","2","''",")","w.add_document","(","type=","''","p","''",",","text=","''","Car","trip","''",")","w.add_document","(","type=","''","p","''",",","text=","''","Dog","eared","''",")","w.add_document","(","type=","''","p","''",",","text=","''","Every","day","''",")","with","w.group","(",")",":","w.add_document","(","type=","''","chap","''",",","text=","''","Chapter","3","''",")","w.add_document","(","type=","''","p","''",",","text=","''","Fine","day","''",")","The","``","NestedParent","``","query","wraps","two","sub-queries",":","the","``","parent","query","''","matches","a","class","of","``","parent","documents","''",".","The","``","sub","query","''","matches","nested","documents","you","want","to","find",".","For","each","``","sub","document","''","the","``","sub","query","''","finds",",","this","query","acts","as","if","it","found","the","corresponding","``","parent","document","''",".",">",">",">","with","ix.searcher","(",")","as","s",":","...","r","=","s.search","(","query.Term","(","``","text","''",",","``","day","''",")",")","...","for","hit","in","r",":","...","print","(","hit","[","``","text","''","]",")","...","Chapter","2","Chapter","3"]
code: def matcher(self, searcher, context=None):
      bits = searcher._filter_to_comb(self.parents)
      if not bits:
          return matching.NullMatcher
      m = self.child.matcher(searcher, context)
      if not m.is_active():
          return matching.NullMatcher
  
      return self.NestedParentMatcher(
          bits,
          m,
          self.per_parent_limit,
          searcher.doc_count_all(),
          self.score_fn,
      )
  
file_path: whoosh/src/whoosh/query/nested.py
imports: from whoosh import matching
  from whoosh.compat import xrange
  from whoosh.query import qcore
  from whoosh.query.wrappers import WrappingQuery
label_desc: Use image node_id 4 for calling the NestedParent obj's underlying member method code with example usage: obj.matcher(searcher, context) and returns: self, matching, matching