cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Display Exact match of a pattern

Hi,

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 ?

Thanks

1 ACCEPTED SOLUTION
4 REPLIES 4

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

Best,
ABK

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”:

CREATE

(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

2X_3_36298e0a5ff77404d918d520b536f5a22bd63be0.png

Hi @dominicvivek06,

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