Match multiple node property values ​​in Cypher / Neo4J

using Cypher 2 I want to find all nodes of a certain label (Context), which are called either "health" or "opinion".

Request in progress:

MATCH (c:Context) WHERE c.name="health" OR c.name="opinion" RETURN c;

But I wonder if Cypher has a syntax that I could put in the first part of MATCH, something like this:

MATCH (c:Context{name:"health"|name:"opinion})

The above example does not work, but I just show it so you know what I mean.

Thank!

+3
source share
2 answers

Alternatively, you can do this:

MATCH (c:Context) WHERE c.name IN ['health', 'opinion'] RETURN c

Still not indicated in the MATCH instruction, but a little easier as the list of possible values ​​increases.

+6
source

You could do

MATCH (c:Context {name:"health"}), (d:Context { name:"opinion"}) 
RETURN c,d
+2
source

All Articles