The following code is worked well
SELECT * FROM cypher('age_graph', $$
MATCH (a)-[:LocatedAt*]->(c:City)
MATCH (a:Airport)-[e:Flight*]->(b:Airport)
MATCH (b)-[:LocatedAt*]->(c1:City)
RETURN c, a, e, b, c1
$$) AS (c agtype, airport1 agtype,e agtype , airport2 agtype, c1 agtype);
But when i want to try to return a property of edges in a path. it shows me an error like below:
SELECT * FROM cypher('age_graph', $$
MATCH (a)-[:LocatedAt*]->(c:City)
MATCH (a:Airport)-[e:Flight*]->(b:Airport)
MATCH (b)-[:LocatedAt*]->(c1:City)
RETURN c, a, e, b, c1, e.arrival_time
$$) AS (c agtype, airport1 agtype,e agtype , airport2 agtype, c1 agtype, arrival agtype);
ERROR: array index must resolve to an integer value
3
Answers
Returning
e.arrival_time
will try to return an array consisting of all the properties of the nodes that matched in your query, thats why you get this kind of error. According to this github issue your query should look like this:The error message is because of that you are trying to access and array using some non-integer value as index. Lets say if value being used here as an index is not a number or if it is float value instead of integer.
The problem is at ‘e.arrival_time’ use different expression instead of this that return an integer value . You can use id property if it is on ‘e’ relationship.
You are using using VLE to match the patterns. VLE match returns an array of edges between two nodes either it contains single or muliple edges.
In order to access properties of edges from VLE, you should either use UNWIND clause (see example 1) or you can use index (see example 2) to retrieve the edge from array and then access properties.
Example 1
OR
Example 2
Also see other questions related to VLE: