Unable to filter out paths containing self edges using a cypher Match query.
See original GitHub issueTrying the following query to get a path using a match query to filter out paths that contain self edges (node with edges to itself to avoid increased length of path:
match p = (base:party{node_id:'245793137123'})<-[trail:ownership*..]-(leaves:party) where none( rel in relationships(p) where startNode(rel) = endNode(rel) ) return count(p)
But this query is unable to filter out the data and I get the entire set.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Neo4J/Cypher: How to filter the nodes of a path?
Is there a way to filter the nodes between the relationships in the first query? Important notes:
Read more >Performing pattern negation to multiple nodes - Neo4j
Correct approach: collect nodes to exclude, and use WHERE NONE() on the collection to drive exclusion ; Ingredient) WHERE ; as excluded MATCH...
Read more >Avoid cycles in Cypher queries | GraphAware
The reason is that when Neo4j traverses the graph with your Cypher query, it uses every edge only once (to prevent endless loops), ......
Read more >Neo4j Cheat Sheet & Quick Reference
A Neo4j cheat sheet with getting started resources and information on how to query the database with ... Matches relationships with the declared...
Read more >Cypher Query Language Reference, Version 9 - Amazon S3
A Cypher query part cannot both match and update the graph at the same time. ... terms as a directed, vertex-labeled, edge-labeled multigraph...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
.neq(' cypher.null')
is guard to handlecypher.null
which represents null in Cypher for Gremlin.We may call “root cause” the following snippet:
This is how variable length path
<-[trail:ownership*..]-
is translated. Basically, it is an imperative way to traverse relationships (21
is limit to avoid infinite loops). If there is a loop, the path will be traversed repeatedly (what happens in the query you’ve provided).So we need to find a better implementation of this in Gremlin, but as I’ve said in the previous message this is a rather complicated task, as there are other edge cases that need to be considered, as well as performance.
Ahh okay. I was working on a fraud detection case.and got stuck here. I saw this query conversion from the cypher in the
gremlin-server.log
file, and I see a.neq(' cypher.null')
in the query and i assume this step is occuring at thenone
where clause. I think this is the root cause of the bug.Hope I could help somehow with this. Thanks!