age icon indicating copy to clipboard operation
age copied to clipboard

some useful cypher statements

Open jihot2000 opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. I find it is difficult when I try to query a link list. I searched and found some useful cypher statements which works for Neo4j.

Describe the solution you'd like

  • UNWIND a vertex list
MATCH p=()-[]->()
WITH nodes(p) AS a
UNWIND a AS b
RETURN b
  • WHERE not a relationship
MATCH (head)-[:edge*]->()
WHERE NOT ()-[:edge]->(head)
RETURN head
  • list generation using IN
MATCH p=()-[]->()
WITH nodes(p) AS a
RETURN [x IN a | x.name]

jihot2000 avatar May 18 '22 11:05 jihot2000

I find 'WHERE NOT EXISTS' can do path pattern not match

MATCH (head)-[:edge*]->()
WHERE NOT EXISTS (()-[:edge]->(head))
RETURN head

jihot2000 avatar May 18 '22 14:05 jihot2000

List comprehension will be upcoming. Unwind should work, we will be looking into that.

jrgemignani avatar May 27 '22 00:05 jrgemignani