Thank you Erick.

I actually do need it to extend to grandchildren as stated in "I need to be able to find *all descendants* of a node with one query". I already have an index that allows me to find the direct children of a node, what I need is to be able to get all descendants of a node (children, grandchildren... etc).

I have submitted this questions on stackoverflow where I put in more details : http://stackoverflow.com/questions/18984183/join-query-in-apache-solr-how-to-get-all-levels-in-hierarchical-data

Semiaddict


Le 24/09/2013 16:08, Erick Erickson a écrit :
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

Reply via email to