Reputation: 496
I've noticed that match(a:Vegetable{name:'Cellery'}) return a
and match(a:Vegetable) where a.name='Cellery' return a
gives me the same result.
Are there any practical differences between the two? The first form seems to work well when you know the property value, but is there a way to use wildcards or a LIKE condition with it?
Upvotes: 5
Views: 1332
Reputation: 5047
The EXPLAIN
and PROFILE
options show the execution plan of the query.
They show the exact same execution plan for both queries (on an empty database).
So performance-wise, the two notations should be completely the same.
The first form seems to work well when you know the property value, but is there a way to use wildcards or a LIKE condition with it?
That's correct, WHERE
gives you a lot more flexibility. Basically, the MATCH
clause only allows you to check for equalities that could be written as WHERE a.prop1 = value1 AND a.prop2 = value2 AND ...
. Meanwhile, WHERE
allows you a lot more: the AND
/OR
/XOR
and NOT
logical operators, checking for inequalities; using STARTS WITH
, CONTAINS
, ENDS WITH
and regular expressions; checking for node types like WHERE (a:SomeLabel)
or even checking if the variables of the match are part of a pattern like WHERE NOT (a)-[:SOME_REL]->(:SomeLabel)
.
Upvotes: 9