1
votes

Following Cypher-Query returns all relationships from a matching relationship-index:

start r=relationship:concept_contained_in_report('concept_id:2') return r

How can I return all the end-nodes of those relationships instead of the relationships itself?

I would expect something like

 start r=relationship:concept_contained_in_report('concept_id:2') return r.end

but that doesn't work since end (the endnode) is not a property of relationship.

Thanks Jorg

2

2 Answers

2
votes

You could try

start r=relationship:concept_contained_in_report('concept_id:2')
match ()-[r]->endNode
return endNode

Basically, match the relationship with its beginning and end. You don't care about the beginning, so don't assign it an identifier. Assign an identifier to the end node and return it.

1
votes

or in Neo4j 2.0+, you may also try the following code:

start r=relationship:concept_contained_in_report('concept_id:2')
return endNode(r) as eNode

they provide a very convenient feature, eh.