Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the label of a relationship

Tags:

If I have the cypher query

MATCH (a)-[r]->(b) 

I can get the labels of a and b fine line so

MATCH (a)-[r]->(b) RETURN labels(a), labels(b) 

But when I want the label of r using the same syntax

MATCH (a)-[r]->(b) RETURN labels(r) 

I get

Type mismatch: expected Node but was Relationship 

How do I return the label of r, the relationship?

like image 928
Christopher Hackett Avatar asked Jun 02 '14 16:06

Christopher Hackett


People also ask

What do labels mean in a relationship?

"When people 'label' a relationship, essentially they are defining their connection and agreeing on how they will refer to their connection and each other. Labels are helpful heuristics (mental shortcuts) for describing or communicating about a relationship," she explains.

How do you know when to label a relationship?

As a rough rule, two months should be a safe amount of time to broach the subject. But every relationship is different, so if it feels right earlier, go for it. If it doesn't feel right at that stage, there are a few steps you can take to build yourself up for the conversation.

How long until you put a label on a relationship?

It takes six weeks from on average for new couples to 'have the talk' and finally put a label on the relationship, according to new research.


1 Answers

In Neo4j, relationships don't have labels - they have a single type, so it would be:

MATCH (a)-[r]->(b) RETURN TYPE(r) 
like image 54
Dan G Avatar answered Oct 19 '22 02:10

Dan G