Sure, index the parent node id (perhaps multiple) with each child and add &fq=parent_id:12.
you can do the reverse and index each node with it's child node IDs to to ask the inverse question. This won't extend to grandchildren/parents, but you haven't stated that you need to do this. Best, Erick On Mon, Sep 23, 2013 at 6:23 PM, Semiaddict <n...@semiaddict.com> wrote: > Hello, > > I am using Solr to index Drupal node relations (over 300k relations on over > 500k nodes), where each relation consists of the following fields: > - id : the id of the relation > - source_id : the source (parent) node id > - targe_id : the targe (child) node id > > I need to be able to find all descendants of a node with one query. > So far I've managed to get direct children using the join syntax of Solr4 > such as (http://wiki.apache.org/solr/Join): > /solr/collection/select?q={!join from=source_id to=target_id}source_id:12 > > Note that each node can have multiple parents and multiple children. > > Is there a way to get all descendants of node 12 without having to create a > loop in PHP to find all children, then all children of each child, etc ? > If not, is it possible to create a recursive query directly in Solr, or is > there a better way to index tree structures ? > > Any help or suggestion would be highly appreciated. > > Thank you in advance, > > Semiaddict