Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-13-2020 03:21 PM
Hey everyone - I am hoping someone can help me convert my syntax for a specific query...
The following query yields the result I desire (seen in the screen shot below):
MATCH (e:Employee)-[r:IS_ALIGNED_TO] ->(t:Territory)-[l:IS_CHILD_OF*] ->(u:Territory)
WHERE u.name CONTAINS "HEALTH" AND e.role CONTAINS "Solutions Architect"
RETURN (e)-[r]->(t)-[l*]->(u)
I understand this is deprecated, however all my efforts thus far haven't yielded the desired result. This is as close as I have gotten:
MATCH p=(e)-[:IS_ALIGNED_TO|:IS_CHILD_OF]-(u)
WHERE e.role="Solutions Architect"
RETURN (e)-[:IS_ALIGNED_TO|:IS_CHILD_OF]-(u)
No matter what I have tried so far I can't seem to get the result with the updated syntax to yield the same result as the first query example...
Any thoughts as to what I am missing?
Solved! Go to Solution.
10-13-2020 09:59 PM
The only part that is currently deprecated is having a variable on a variable-length relationship (this part: [l:IS_CHILD_OF*]
specifically that there is an l
variable present there), however don't let that stop you from using it for now. Deprecations tend to mean that it's safe to use until we offer a replacement, and we'll give fair warning before it's pulled (this usually happens at major releases, and we just did our 4.x major release this year).
So go ahead and keep using it. We don't have a replacement for it for built out, so it's still good to use if you want.
That said, I don't think you really need to make use of it here. If you're only after the visual graph results, then it should be enough just to MATCH and return the matched path:
MATCH path = (e:Employee)-[:IS_ALIGNED_TO]->(:Territory)-[:IS_CHILD_OF*]->(u:Territory)
WHERE u.name CONTAINS "HEALTH" AND e.role CONTAINS "Solutions Architect"
RETURN path
10-13-2020 05:48 PM
Try this:
MATCH (e)-[:IS_ALIGNED_TO]-(u)
WHERE e.role="Solutions Architect"
WITH e, u
MATCH (u)-[:IS_CHILD_OF]-(t:Territory)-[:IS_CHILD_OF]-(t1:Territory)
WITH e, u, t, t1
RETURN e, u, t, t1
10-13-2020 09:59 PM
The only part that is currently deprecated is having a variable on a variable-length relationship (this part: [l:IS_CHILD_OF*]
specifically that there is an l
variable present there), however don't let that stop you from using it for now. Deprecations tend to mean that it's safe to use until we offer a replacement, and we'll give fair warning before it's pulled (this usually happens at major releases, and we just did our 4.x major release this year).
So go ahead and keep using it. We don't have a replacement for it for built out, so it's still good to use if you want.
That said, I don't think you really need to make use of it here. If you're only after the visual graph results, then it should be enough just to MATCH and return the matched path:
MATCH path = (e:Employee)-[:IS_ALIGNED_TO]->(:Territory)-[:IS_CHILD_OF*]->(u:Territory)
WHERE u.name CONTAINS "HEALTH" AND e.role CONTAINS "Solutions Architect"
RETURN path
10-14-2020 04:50 AM
Thanks, folks! For this specific query I can definitely get away with the exact match, but there are other instances where the match(es) I am looking for are variable path lengths away... I will adjust as necessary and await the updated syntax!
All the sessions of the conference are now available online