undefined
undefined

Reputation: 34309

Filter relationships by a property Neo4j

If i create some relationships with properties

CREATE (a:A)
CREATE (b:B)
CREATE (a) - [:Thing { thing:1 }] -> (b)
CREATE (a) - [:Thing { thing:2 }] -> (b)
CREATE (a) - [:Thing { thing:3 }] -> (b)
CREATE (a) - [:Thing { thing:4 }] -> (b)

Is there a way of querying them to retrieve a subset of those relationships?

If I do the following:

MATCH (a:A) - [r:Thing] -> (b:B)
where r.thing > 2
return r

I get back all 4 of the relationships not just the last two.

Upvotes: 5

Views: 2053

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30407

Your query is correct, and the output is correct (only relationships with thing equal to 3 and 4 are returned).

I think the problem is you're only looking at the graph output instead of the row or text output (look at the view options on the left side of the results), and the auto-complete option in the corner of the graph view is on, showing the remaining relationships even if they aren't in the returned set. If you want the graph view to ONLY show what's returned in the query results, turn auto-complete off.

Upvotes: 6

Related Questions