How To know the properties on which relationship is formed in neo4j between 2 labels

Hello Team,

Let say some X person has created the relationship between 2 labels.
And Y person want to know on which properties of labels relationship was made.
Then Let me know to identify or know the properties name on which specific relationship is made.

Best Regards

If have a MATCH statement such as:

MATCH (x:Person)-[r:RELATED_TO]-(y:Person)
WHERE = 'xxx' AND = 'yyy'
RETURN keys(r)

will return the names of the properties for relationship r.

Is that what you are asking?


Hello Elaine,

Once the relationship is built , How to know on which properties relationship is made if someone is not having the above query ?

We have only 2 label names and 1 relationship name between those 2 labels.

So we need to find out the properties name on which relationship is made assuming we dont have query which creates the relationship.


If you took the WHERE clause out of the query, then it would return the list of properties for each relationship between the two nodes.

Each relationship could have a different list of properties.


Let me explain u my aks using attached image. And then please help me in telling on which join condition ( property name ) relationship is built between 2 nodes.

I think I understand the confusion.

Relationships in Neo4j, while similar to table joins in SQL, are different in some ways. A relationship does not imply that there is a specific join condition on properties. The properties may be entirely different. Neo4j does not have foreign keys, and relationships do not require that some properties are the same.

Any criteria for why a relationship was created is not captured in the created relationship. If you really need to have that information, then you need to add that somehow as a property in your graph, and how you do it, what format, is entirely up to you.

As an example, if a CSV load was used to create relationships between already existing nodes, and we had :Author nodes and :Book nodes, it's possible that we were matching to :Author nodes by their name, or maybe by their id, or their SSN. :Book nodes could be matched to by title, or by id. Or maybe we matched to them in some other way, matching to a specific genre, then related books of that genre, and we created :WROTE relationships between a certain author to all books in that genre (incorrect, but still possible to do this).

We do not save what query or conditions were used to figure out how the nodes were matched prior to creating a relationship between them, and we don't even know if properties were involved when matching to the nodes in the first place.

Hello Andrew,

Now I got your point.
In a nutshell , There is no way by-default in neo4j to identify or know using which properties a specific relationship is created.

Thanks !!


Almost got it. The part you might be missing is that properties might not even be involved at all. Or maybe you're matching to one of the nodes through some alternate path.

The thing to understand is that there are any number of ways you can match to the nodes that you will use to create a relationship, it won't always be through filtering by their properties, and the properties between the two nodes might not have any similarity at all.

In other words, properties on nodes don't need to have any connection or relation to how the nodes are matched, or to the relationship that you create.

I've found sometimes when designing my neo4j databases, it can be helpful to create a .source property on a relationship. This 'metadata' may be helpful to identify the query (or script) that was used to create the relationship in the first place.

You can always delete these properties later if you find you don't need or use them, but during the design or dev phase it may be helpful in debugging.

for example:

// This is the Nodelabel to Anotherlabel function:
MATCH (n:Nodelabel) where some where clause is true
MATCH (x:Anotherlabel) where some where clause is true
SET r.source='created by the Nodelabel to Anotherlabel function in scriptxyz.cypher which was based on the vendor property matching'