How do I return all the labels for a node using a Cypher query? Note that I don't know the node id in advance, I do some sort of index match to get it.
You can get labels by using the labels()
method.
Example (Neo4j 2.0):
Lets say you have the "name" property indexed and would like to search on that basis, the following query would give you all nodes and their labels which have name = "some_name"
MATCH (r) WHERE r.name="some_name" RETURN ID(r), labels(r);
If you know one of the labels of the starting node, that's even better. For some known label called "Label", this query would give you all nodes along with all labels that are associated with the node.
MATCH (r:Label {name:"some_name}) RETURN ID(r), labels(r);
Need more assistance? Go through the Cypher docs! for labels()