Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-14-2021 03:01 AM
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
Solved! Go to Solution.
01-15-2021 04:13 AM
01-14-2021 06:57 AM
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 pathsr.property1=X
is true
RETURN p
returns all pathsWhat 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
01-15-2021 03:19 AM
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?
01-15-2021 04:13 AM
can you uncheck this setting
01-15-2021 05:22 AM
Hi @dominicvivek06,
Thank you so much for your reply. This is what I expected.
Thank you
All the sessions of the conference are now available online