We wrote a recursive query as a server side JavaScript function that takes 
the parent "rid" as a parameter. Have not tested the performance but seems 
powerful and flexible, since as you traverse down you get to analyze your 
current results.


var db = orient.getGraph();
var root;
var roorArr;
var children = [];
var cmd;


cmd = "select from  #"+ rid;
rootArr = db.command("sql",cmd,[]);
root = rootArr[0];
root = JSON.parse(root.getRecord().toJSON());
root.children = [];
children.push(root);
queryChildren(root.children, "#" + rid);
function queryChildren(childrenArray, rid) {
var arr;
var record;
var child;
arr = NavTreeGetChildrenByFullId(rid);
for (var j = 0; j < arr.length; j++) {
record = arr[ j ];
child = {};
child = JSON.parse(record.getRecord().toJSON());
child.children = [];
childrenArray.push(child);

queryChildren(child.children, child[ "@rid" ]);
}
}
return children;


On Thursday, September 24, 2015 at 11:19:43 AM UTC-7, Geoff Goodman wrote:
>
> I would suggest experimenting with the pattern to see how it could be 
> expanded to a 2nd level.
>
> On Thu, Sep 24, 2015 at 1:06 PM Eric Lin <[email protected] <javascript:>> 
> wrote:
>
>> Hey Geoff,
>>
>> I gave that a shot and that gives me the first item and nested nodes one 
>> step away only. I need nested nodes up to two steps away with a given edge.
>>
>> so if we have
>>
>> root_node --> first_child --> second_child
>>
>> That query gives me the 'root_node' with the nested 'first_child'. 
>> Doesn't give me the nested 'second_child's inside the 'first_child'.
>>
>> Any ideas there?
>>
>> Cheers,
>> Eric
>>
>> On Thursday, September 24, 2015 at 8:30:35 AM UTC-7, Geoff Goodman wrote:
>>>
>>> Try this:
>>>
>>> SELECT *, out('hasEdge')[0] as second_node FRPM #11:1 FETCHPLAN 
>>> second_vertexes:0
>>>
>>> This is partly from memory and partly from a query I built to achieve 
>>> something similar to what you're looking for.
>>>
>>> Geoff
>>>
>>
>>>
>>> On Tuesday, September 8, 2015 at 8:08:13 PM UTC-4, Eric Lin wrote:
>>>>
>>>> So I haven't found a good solution to this, as of now I'm making this 
>>>> query:
>>>>
>>>> SELECT *, out('hasEdge') as first_vertexes, out('hasEdge').out(
>>>> 'hasEdge') as second_vertexes FROM #11:1 FETCHPLAN first_vertexes:1 
>>>> second_vertexes:1
>>>>
>>>> and in the resulting rows that I get I manually match the the in's and 
>>>> the out's @rids for the first and second vertexes and building the nested 
>>>> object before sending it in the json response.
>>>>
>>>> Seems like there must be a better way but I can't have this be a 
>>>> blocker for me so... temporary solution until someone can figure something 
>>>> else out.
>>>>
>>>> Cheers,
>>>> Eric
>>>>
>>> -- 
>>
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "OrientDB" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/orient-database/qfzP4gE4vwU/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to