Hi Shamik, you could try solr grouping using group.query construct. you could discard the child match from the result i.e. any doc that has parent_doc_id field and use join to fetch the parent record
q=*:*&group=true&group.query=title:title2&group.query={!join from=parent_doc_id to=doc_id}parent_doc_id:*&group.limit=10 Thanks, Susmit On Tue, Apr 19, 2016 at 10:29 AM, Shamik Bandopadhyay <sham...@gmail.com> wrote: > Hi, > > I have a set of documents indexed which has a pseudo parent-child > relationship. Each child document had a reference to the parent document. > Due to document availability complexity (and the condition of updating both > parent-child documents at the time of indexing), I'm not able to use > explicit block-join.Instead of a nested structure, they are all flat. > Here's an example: > > <doc> > <field name="id">1</field> > <field name="title">Parent title</field> > <field name="doc_id">123</field> > </doc> > <doc> > <field name="id">2</field> > <field name="title">Child title1</field> > <field name="parent_doc_id">123</field> > </doc> > <doc> > <field name="id">3</field> > <field name="title">Child title2</field> > <field name="parent_doc_id">123</field> > </doc> > <doc> > <field name="id">4</field> > <field name="title">Misc title2</field> > </doc> > > What I'm looking is if I search "title2", the result should bring back the > following two docs, 1 matching the parent and one based on a regular match. > > <doc> > <field name="id">1</field> > <field name="title">Parent title</field> > <field name="doc_id">123</field> > </doc> > <doc> > <field name="id">4</field> > <field name="title">Misc title2</field> > </doc> > > With block-join support, I could have used Block Join Parent Query Parser, > q={!parent which="content_type:parentDocument"}title:title2 > > Transforming result documents is an alternate but it has the reverse > support through ChildDocTransformerFactory > > Just wondering if there's a way to address query in a different way. Any > pointers will be appreciated. > > -Thanks, > Shamik >