Reputation: 534
A node's property has 6 categories. I'd like to leave all the nodes with this property not equal to one of the categories.
It's easy to do with WHERE
like this:
MATCH (a)
WHERE a.property <> "category"
RETURN a
I'd like to do it another way without where
because it seems to be more efficient. I imagine it like this:
MATCH ( a {property <> "category"} )
RETURN a
Is it possible?
Upvotes: 0
Views: 83
Reputation: 8833
Neo4j MATCH does not have a syntax to inline WHERE NOT <property>=<value>
. Furthermore, Cypher is declarative, meaning it only defines what to return, not how to return it. So MATCH (n{id:1})
is equivalent (in execution) to MATCH (n) WHERE n.id=1
. The only time WHERE vs inline produces different execution plans is when you don't pair the WHERE clause with the MATCH. By trying to "optimize" your cypher for execution, most of the time you will just be getting in the Cypher planners way. (Unless your original cypher was over complicated)
Upvotes: 3