问题
Cypher query:
MATCH (x) WHERE x.uuid = "41f64ab1-6009-4e95-b22b-c833525f6edb" MATCH p =
(o)-[:CONTAINS|:HAVING*]->(x) WHERE labels(o) IN ['Box', 'Package'] RETURN p
Running it in Neo4j browser results in a warning:
**WARNING: This feature is deprecated and will be removed in future versions.**
The semantics of using colon in the separation of alternative relationship
types in conjunction with the use of variable binding, inlined property
predicates, or variable length will change in a future version.
How can I re-write this query to eliminate this warning?
Thanks in advance.
回答1:
This deprecation is not about inability of using relationship type alternatives but about its syntax – see cypher deprecations in version 3.2. Only first type has colon now, i.e. not :R1|:R2
but :R1|R2
. Deprecation warning in Neo4j browser suggests that former syntax will have new semantics in the future.
Specifying relationship type in a pattern is actually much more effective than filtering paths ex-post which is the way that the workaround by Tom Geudens is executed.
回答2:
This might do it :
MATCH (x) WHERE x.uuid = "41f64ab1-6009-4e95-b22b-c833525f6edb"
MATCH p = (o)-[*]->(x)
WHERE labels(o) IN ['Box', 'Package']
AND ALL (rs IN relationships(p) WHERE type(rs) IN ['CONTAINS','HAVING'])
RETURN p
Hope this helps.
Regards, Tom
来源:https://stackoverflow.com/questions/45790779/alternative-relationship-deprecated-warning