Serching a list in a list

I'm using the Community edition v4.6

I have some nodes with multiple labels, say ["Asset", "M", "M10", "M20"]
So, I can have a (:Asset:M:M10) or a (:Asset:M:M20) but also I can have (:Asset:M) nodes

How can I query neo4j to return all nodes which are (:Asset:M) but not M10 or M20?

I tried with

MATCH (n:Miura)
    WHERE NOT any(word IN labels(n) WHERE any(word1 in ["M10","M20"] CONTAINS word))
RETURN n, labels(n) LIMIT 25 

But it returns an error:

any(...) requires a WHERE predicate (line 2, column 39 (offset: 54))
"WHERE NOT any(word IN labels(n) WHERE any(word1 in ["M10","M20"] CONTAINS word))"
                                       ^

Any suggestion will be appreciated. TIA

The syntax is little off.

MATCH (n:Miura)
    WHERE NOT any(word IN labels(n) WHERE any(word1 in ["M10","M20"] WHERE word1 = word))
RETURN n, labels(n) LIMIT 25 

Or, a simplified version:

MATCH (n:Miura)
    WHERE none(word IN labels(n) WHERE word in ["M10","M20"])
RETURN n, labels(n) LIMIT 25 

Based on your requirement, I would think the following would work.

Match (n:Asset:M) 
Where not n:M10 and not n:M20
Return n 
1 Like

@glilienfield As always, you have an answer for everything! Thank you!

Try this:
MATCH (n) where labels(n) = ['M']
RETURN n

In terms of execution plan, there is an enormous differences. The @glilienfield performs better!