Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-06-2021 02:11 AM
I have e problem with 'filter'. It is no supported .
Query is a part from "GraphGist - Information Flow Through a Network"
// Find all unique, simple paths from one city to another
MATCH p=(:City { name: "Tokyo" })-[:BACKBONE_TO*]-(:City { name: "Chicago" })
WHERE all(c IN nodes(p) WHERE 1=length(filter(m IN nodes(p) WHERE m=c)))
RETURN DISTINCT extract(n IN nodes(p) | n.name) AS Path, length(p) AS Length
How to transform it to working query ?
Solved! Go to Solution.
07-06-2021 02:43 AM
07-06-2021 02:29 AM
Hello @ilko.k.v
You must use a comprehension list:
// Find all unique, simple paths from one city to another
MATCH p=(:City {name: "Tokyo"})-[:BACKBONE_TO*]-(:City {name: "Chicago"})
WHERE all(c IN nodes(p) WHERE 1=size([m IN nodes(p) WHERE m=c]))
RETURN DISTINCT [n IN nodes(p) | n.name] AS Path, length(p) AS Length
Regards,
Cobra
07-06-2021 02:36 AM
I try with
MATCH p=(:City { name: "Tokyo" })-[:BACKBONE_TO*]-(:City { name: "Chicago" })
WHERE all(c IN nodes(p) WHERE 1=length(RETURN[m IN nodes(p) WHERE m=c]))
RETURN DISTINCT extract(n IN nodes(p) | n.name) AS Path, length(p) AS Length
But return error:
Invalid input 'WHERE': expected
"OR"
"XOR"
"AND"
"=" ...
07-06-2021 02:37 AM
There is no extract
in the query I gave you. I also replaced it with a comprehension list.
07-06-2021 02:42 AM
Error is coming from "WHERE 1="
07-06-2021 02:43 AM
Why is there a RETURN
in your WHERE
clause?
07-06-2021 02:47 AM
Thank you Cobra
Working
MATCH p=(:City { name: "Tokyo" })-[:BACKBONE_TO*]-(:City { name: "Chicago" })
WHERE all(c IN nodes(p) WHERE 1=size([m IN nodes(p) WHERE m=c]))
RETURN DISTINCT [n IN nodes(p) | n.name] AS Path, length(p) AS Length
07-07-2021 02:09 PM
The Graph Gist Example should be updated now. Thanks for raising it.
All the sessions of the conference are now available online