I am having a issue to retrieve path in neo4j exclude certain label.
Foe example, I have
-->(h)-->(j)
/
(a)-->(b)-->(c)-->(d)-->(i)
\
-->(f)-->(g)
with h
node has a Deleted
label.
I have query
MATCH path = (n)-[*]->(child) where id(n)={id of node a} and NOT child:Deleted RETURN path
then I want this query to return the full path but exclude the subtree of node h
since node h
is Deleted
.
the return tree should be like
(a)-->(b)-->(c)-->(d)-->(i)
\
-->(f)-->(g)
But the query seems not working.
Can any one help me with this.
Thanks
If you want to get the labels of a specify node, then use labels(node) ; If you only want to get all node labels in neo4j, then use this function instead: call db. labels; , never ever use this query: MATCH n RETURN DISTINCT LABELS(n) .
An OPTIONAL MATCH matches patterns against your graph database, just like a MATCH does. The difference is that if no matches are found, OPTIONAL MATCH will use a null for missing parts of the pattern. OPTIONAL MATCH could be considered the Cypher equivalent of the outer join in SQL.
You can change the nodes associated with a label but you can't change the type of a relationship. Conceptually, if you take your chicken out of one coop and put it in another you haven't altered the substance of the chicken.
Non-alphabetic characters, including numbers, symbols and whitespace characters, can be used in names, but must be escaped using backticks. For example: `^n` , `1first` , `$$n` , and `my variable has spaces` .
What worked for me is a list comprehension over nodes in the path:
MATCH path = ()-[*]->()
WHERE NONE(n IN nodes(path) WHERE n:Deleted)
RETURN path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With