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.
The graphs in the Neo4j Graph Data Science Library support properties for relationships. We provide multiple operations to work with the stored relationship-properties in projected graphs. Relationship properties are either added during the graph projection or when using the mutate mode of our graph algorithms.
When you want to return all nodes, relationships and paths found in a query, you can use the * symbol. This returns the two nodes, the relationship and the path used in the query.
Contents. The CREATE clause is used to create nodes and relationships.
Properties are stored as a linked list of property records, each holding a key and value and pointing to the next property. Each node and relationship references its first property record. The Nodes also reference the first relationship in its relationship chain. Each Relationship references its start and end node.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With