I tried to index a 3-level nested Block and expected the "1.2.1" document to have _root_=1.2 but it had the top-document as root. If each doc in addition would have a _parent_=<id> field pointing to its nearest parent, then it would be possible to extend the [child] doc transformer to reconstruct the correct level. Risk is of course that you may construct such a query that would only bring back GRANDCHILD docs, but in that case the [child] transformer could go fetch the CHILD since it would have its id, and nest itself all the way to the _root_ until the full doc is reconstructed? Any thoughts on this approach? In what phase would we need to add the _parent_ field?
-- Jan Høydahl > 14. mar. 2018 kl. 13:56 skrev Jan Høydahl <jan...@apache.org>: > > I understand that the [subquery] transformer can help build a nested response > when you know the structure in advance, but what if you have some BlockJoin > indexed structure with grand children (as the original question in this > thread), and you want to reconstruct the full document based on what is > returned by the {!parent} query? I cannot see how to use [subquery] to do > this? > > Jan > > On 2016/03/24 20:52:51, Mikhail Khludnev <mkhlud...@griddynamics.com> wrote: >> I think you cal already kick tires and contribute a test case into >> https://issues.apache.org/jira/browse/SOLR-8208 that's already reachable >> there I believe, but I still working on core design. >> >> On Thu, Mar 24, 2016 at 10:02 PM, Alisa Z. <prol...@mail.ru> wrote: >> >>> Hi all, >>> >>> I apologize for duplicating my previous message: >>> Solr 5.3: anything similar to ChildDocTransformerFactory that does not >>> flatten the hierarchical structure? >>> >>> However, it is still an open and interesting question: >>> >>> Following the example from https://dzone.com/articles/using-solr-49-new >>> , let's say we are given multiple-level nested structure: >>> >>> <doc> >>> <field name="id">1</field> >>> <field name="name">I am the parent</field> >>> <field name="cat">PARENT</field> >>> <doc> >>> <field name="id">1.1</field> >>> <field name="name">I am the 1st child</field> >>> <field name="cat">CHILD</field> >>> </doc> >>> <doc> >>> <field name="id">1.2</field> >>> <field name="name">I am the 2nd child</field> >>> <field name="cat">CHILD</field> >>> <doc> >>> <field name="id">1.2.1</field> >>> <field name="name">I am a grandchildren</field> >>> <field name="cat">GRANDCHILD</field> >>> </doc> >>> </doc> >>> </doc> >>> >>> >>> Querying >>> q={!parent which="cat:PARENT"}name:(I am +child)&fl=id,name,[child >>> parentFilter=cat:PARENT] >>> >>> will return flattened structure, where cat:CHILD and cat:GRANDCHILD >>> documents end up on the same level: >>> <doc> >>> <field name="id">1</field> >>> <field name="name">I am the parent</field> >>> <field name="cat">PARENT</field> >>> <doc> >>> <field name="id">1.1</field> >>> <field name="name">I am the 1st child</field> >>> <field name="cat">CHILD</field> >>> </doc> >>> <doc> >>> <field name="id">1.2</field> >>> <field name="name">I am the 2nd child</field> >>> <field name="cat">CHILD</field> >>> </doc> >>> <doc> >>> <field name="id">1.2.1</field> >>> <field name="name">I am a grandchildren</field> >>> <field name="cat">GRANDCHILD</field> >>> </doc> >>> </doc> Indeed, the JAVAdocs for ChildDocTransformerFactory say: "This >>> transformer returns all descendants of each parent document in a flat list >>> nested inside the parent document". >>> >>> Yet is there any way to preserve the hierarchy in the response? I really >>> need to find the way to preserve the structure in the response. >>> >>> Thank you in advance! >>> >>> -- >>> Alisa Zhila >>> ---------------------------------------------------------------------- >>> >> >> >> >> -- >> Sincerely yours >> Mikhail Khludnev >> Principal Engineer, >> Grid Dynamics >> >> <http://www.griddynamics.com> >> <mkhlud...@griddynamics.com> >>