Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match several node property values in Cypher / Neo4J

Tags:

neo4j

cypher

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

The query that works is:

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

But I'm wondering if Cypher has a syntax that I could put it into the first MATCH part, something like this:

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

The example above doesn't work, but I'm just showing it to let you know what I mean.

Thank you!

like image 653
Aerodynamika Avatar asked Dec 11 '22 07:12

Aerodynamika


1 Answers

Alternatively, you can do this:

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

Still not in the "MATCH" statement, but a little easier as your list of possible values grows.

like image 63
Eric Avatar answered Dec 13 '22 20:12

Eric