Display Exact match of a pattern


How to extract and display an exact query using Cypher without other extra information ?
Given the following query:
MATCH p=(A)-[r:relationship]-(B) where r.property1=X return p

so the query doesn't return the nodes with only the relations with property = X but it displays all relationships between the nodes including r.property1=X.

Question: How to remove the rest of relationships and display only the relations with r.property1=X ?


Hi @softLog !

[edited: you do want the paths]

In your query...

MATCH p=(A)-[r:relationship]-(B) where r.property1=X return p
  • p is bound to all paths
  • where the predicate r.property1=X is true
  • RETURN p returns all paths

What is the variable X bound to? Is it possible the predicate is always true?

For example, this works in the classic "Movies" graph to get paths between Persons and Movies where the person acted in a role called "Neo"...

MATCH p=(:Person)-[r:ACTED_IN]->(:Movie) WHERE "Neo" in r.roles RETURN p


Dear ABK,

Thank you very much for your quick reply and help.

Based on you example, I try to explain well the problem which is very simple. We take the same classic "Movies" graph but I add a property in the relationship 'ACTED_IN'. The property is for example β€œyear”:


(Keanu)-[:ACTED_IN {roles:['Neo'], year:['1999']}]->(TheMatrix),

(Keanu)-[:ACTED_IN {roles:['Neo'], year:['2001']}]->(TheMatrix),

(Keanu)-[:ACTED_IN {roles:['Neo'], year:['2003']}]β†’(TheMatrix)

but when I want to extract and display only the edge having the property: r.year = '1999'.
It shows all the edges between Keanu and TheMatrix instead of the unique edge having the property 1999. However the result in text format as well as
the table format is correct. There is only a confusion in the display
of the results.

Here is the result between the display of the graph and the table format. Why does'nt display the same result as the table format?

can you uncheck this setting


1 Like

Hi @dominicvivek06,

Thank you so much for your reply. This is what I expected.
Thank you :slight_smile: