Jack Daniel
Jack Daniel

Reputation: 2611

Neo4j - Return nodes which doesn't have a specific key

I want to return the nodes which does't have a specific key.

Nodes:

A(1:"xa",2:"ya",3:"za")         
B(1:"xb",2:"yb",3:"zb")        
C(2:"yc",3:"zc") 

Now, I want to return C node because it doesn't have a key called 1.

My Approach:

MATCH (n:Company) 
with n,keys(n) as keys_set 
WIth n,keys_set, max(size(keys_set)) As maxi 
RETURN n where keys_set < maxi

Error:

Invalid input 'h': expected 'i/I' (line 1, column 99 (offset: 98)) "MATCH (n:Company) with n,keys(n) as keys_set WIth n,keys_set,max(size(keys_set))As maxi RETURN n where keys_set

Upvotes: 1

Views: 164

Answers (1)

Brian Underwood
Brian Underwood

Reputation: 10856

MATCH (n:Company)
WHERE NOT EXISTS(n.`1`)
RETURN n

Upvotes: 1

Related Questions