Reputation: 185
I'm using graph common neighbours, but I only need the resulting vertexes to be returned, no need for fancy
[
{collection/1:{
collection/2:[
{_id:3 ...},
{_id:7 ...}
]
}
]
I need only the part _id:3 and _id:7 returned:
[
{_id:3 ...},
{_id:7 ...}
]
now I'm trying to break my head how to apprach this, as it's not list I can not FLATTEN it. Is there some hidden feature or hook to return only resulting vertices? Or should I do this manually using two GRAPH_NEIGHBORS query, as I believe that what it does in general, and limit the second query with first query?
Upvotes: 2
Views: 106
Reputation: 263
the reason for the results structure is that you can call it with examples instead of single vertices. In your case of course it is obvious to which vertex pair the neighbors belong. To sort your result you could do the following:
FOR entry IN GRAPH_COMMON_NEIGHBORS("nodes", "node/137789480179", "node/137987398899", {maxDepth : 2}, {maxDepth : 2}) LET X = entry["node/137789480179"]["node/137987398899"] FOR v IN X SORT v.name DESC RETURN v
Upvotes: 0
Reputation: 185
OK final query to return results in format I want:
FOR entry
IN GRAPH_COMMON_NEIGHBORS('nodes', "node/137789480179", "node/137987398899", {direction: 'outbound'}, {direction: 'outbound'})
FOR a in ATTRIBUTES(entry) FOR b in ATTRIBUTES(entry[a]) RETURN entry[a][b]
It returns the result as I wanted, though It still may take some improvements like sorting of results by title alphabetically... I have tried and it does not work.
Upvotes: 1