Reputation: 1335
I'm using NEO4j 3.0 and as attribute I had a dictionnary. Here is an example for an property of a relationship:
R1 :2016-09:{'x': 296, 'y': 8}
R2 : 2016-08:{'x': 481, 'y': 13}
R3 : 2016-08:{'x': 300, 'y': 13}
I'm looking to retrieve paths that the key 'x' satisfied certain conditions for a certain date. So, I tried this as suggested in old post :
MATCH (A:Airport {code:'AAA'}),
(B:Airport {code:'BBB'}),
(A)-[r:`2016-08`]-(B)
WHERE r.x>'300'
RETURN r
It sould give me only R2 but I get nothing.
So, I'm looking for the syntaxe to retrieve the value of key when the property key is a dictionary.
Thank you
Upvotes: 1
Views: 373
Reputation: 11715
If your relationship is created like
MATCH (a:Airport {code: "AAA"}), (b:Airport {code: "BBB"})
CREATE (a)-[:`2016-08` {x: 296, y: 8}]->(b)
it has 2 properties (x
and y
) which you can query and use in WHERE
clauses, return, whatever.
If, however, you create a single property with a complex JSON-like structure inside as a string like this
MATCH (a:Airport {code: "AAA"}), (b:Airport {code: "BBB"})
CREATE (a)-[:`2016-08` {prop: "{x: 296, y: 8}"}]->(b)
you can't query the content of the prop
property: it's a string and opaque to the Cypher engine. You only get string operations, like STARTS WITH
, ENDS WITH
, CONTAINS
, etc.
TL;DR if you need to query something, it needs to be a property by itself.
Upvotes: 2