Krishna Shetty
Krishna Shetty

Reputation: 1441

Cypher - Return node if relationship not present with node of particular label

Please see similar answer at : https://stackoverflow.com/a/14254214/1060044

I have a requirement where I have pattern like below:

MATCH (b:Label1{id:123})<--(Label2)<--(a:Label3) WHERE NOT (a)<--(Label4) return a;

I am getting syntax error with this query. Is there any efficient way to achieve this?

I am using neo4j community version 2.1.2

Upvotes: 0

Views: 349

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39905

When using labels in Cypher, you always have to use a colon : in front of them:

MATCH (b:Label1{id:123})<--(:Label2)<--(a:Label3) WHERE NOT (a)<--(:Label4) return a;

So from node 123 having label Label1 you follow a incoming relationship to a node with label Label2, to node a with label Label3 and you make sure that a is not connection with any node node labelled Label4.

Upvotes: 1

Related Questions