class_docstr: This is the reverse of a :class:`NestedParent` query: instead of taking
  a query that matches children but returns the parent, this query matches
  parents but returns the children.
  
  This is useful, for example, to search for an album title and return the
  songs in the album::
  
      schema = fields.Schema(type=fields.ID(stored=True),
                             album_name=fields.TEXT(stored=True),
                             track_num=fields.NUMERIC(stored=True),
                             track_name=fields.TEXT(stored=True),
                             lyrics=fields.TEXT)
      ix = RamStorage().create_index(schema)
  
      # Indexing
      with ix.writer() as w:
          # For each album, index a "group" of a parent "album" document and
          # multiple child "track" documents.
          with w.group():
              w.add_document(type="album",
                             artist="The Cure", album_name="Disintegration")
              w.add_document(type="track", track_num=1,
                             track_name="Plainsong")
              w.add_document(type="track", track_num=2,
                             track_name="Pictures of You")
              # ...
          # ...
  
  
      # Find songs where the song name has "heaven" in the title and the
      # album the song is on has "hell" in the title
      qp = QueryParser("lyrics", ix.schema)
      with ix.searcher() as s:
          # A query that matches all parents
          all_albums = qp.parse("type:album")
  
          # A query that matches the parents we want
          albums_with_hell = qp.parse("album_name:hell")
  
          # A query that matches the desired albums but returns the tracks
          songs_on_hell_albums = NestedChildren(all_albums, albums_with_hell)
  
          # A query that matches tracks with heaven in the title
          songs_with_heaven = qp.parse("track_name:heaven")
  
          # A query that finds tracks with heaven in the title on albums
          # with hell in the title
          q = query.And([songs_on_hell_albums, songs_with_heaven])
class_docstr_tok: ["This","is","the","reverse","of","a",":","class",":","`","NestedParent","`","query",":","instead","of","taking","a","query","that","matches","children","but","returns","the","parent",",","this","query","matches","parents","but","returns","the","children",".","This","is","useful",",","for","example",",","to","search","for","an","album","title","and","return","the","songs","in","the","album",":",":","schema","=","fields.Schema","(","type=fields.ID","(","stored=True",")",",","album_name=fields.TEXT","(","stored=True",")",",","track_num=fields.NUMERIC","(","stored=True",")",",","track_name=fields.TEXT","(","stored=True",")",",","lyrics=fields.TEXT",")","ix","=","RamStorage","(",")",".create_index","(","schema",")","#","Indexing","with","ix.writer","(",")","as","w",":","#","For","each","album",",","index","a","``","group","''","of","a","parent","``","album","''","document","and","#","multiple","child","``","track","''","documents",".","with","w.group","(",")",":","w.add_document","(","type=","''","album","''",",","artist=","''","The","Cure","''",",","album_name=","''","Disintegration","''",")","w.add_document","(","type=","''","track","''",",","track_num=1",",","track_name=","''","Plainsong","''",")","w.add_document","(","type=","''","track","''",",","track_num=2",",","track_name=","''","Pictures","of","You","''",")","#","...","#","...","#","Find","songs","where","the","song","name","has","``","heaven","''","in","the","title","and","the","#","album","the","song","is","on","has","``","hell","''","in","the","title","qp","=","QueryParser","(","``","lyrics","''",",","ix.schema",")","with","ix.searcher","(",")","as","s",":","#","A","query","that","matches","all","parents","all_albums","=","qp.parse","(","``","type",":","album","''",")","#","A","query","that","matches","the","parents","we","want","albums_with_hell","=","qp.parse","(","``","album_name",":","hell","''",")","#","A","query","that","matches","the","desired","albums","but","returns","the","tracks","songs_on_hell_albums","=","NestedChildren","(","all_albums",",","albums_with_hell",")","#","A","query","that","matches","tracks","with","heaven","in","the","title","songs_with_heaven","=","qp.parse","(","``","track_name",":","heaven","''",")","#","A","query","that","finds","tracks","with","heaven","in","the","title","on","albums","#","with","hell","in","the","title","q","=","query.And","(","[","songs_on_hell_albums",",","songs_with_heaven","]",")"]
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.NestedChildMatcher(
          bits,
          m,
          searcher.doc_count_all(),
          searcher.reader().is_deleted,
          boost=self.boost,
      )
  
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 2 for calling the NestedChildren obj's underlying member method code with example usage: obj.matcher(searcher, context) and returns: self, matching, matching