3
votes

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!

2
Use the one that works, there is no shorthand syntax for that.Michael Hunger
Is there a particular problem you are trying to solve?jjaderberg
@jjaderberg well yes, that was the problem :) i solved it but was just wondering if there was a more efficient way.Aerodynamika
Did you ever find an answer to this @deemeetree ?Henri Cook

2 Answers

11
votes

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.

2
votes

You could do

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