I want to pass to my neography query using cypher a relationship, and have the query execute on that relationship.
I currently get an error:
query_response = @neo.execute_query("MATCH (fromNode)-[{relationship}]->(toNode)
WHERE fromNode.bot_client_id = {bot_client_id} AND toNode.epoch_utc_i > {fromTime} AND toNode.epoch_utc_i < {toTime}
RETURN toNode.value
LIMIT {limit}",
{
:fromTime => fromTime, :toTime => toTime, :bot_client_id => @bot_client_id,
:limit => limit, :relationship => relationship.to_sym
}
)
Neography::SyntaxException: Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. "{id: {param}.id}") (line 1, column 21 (offset: 20))
"MATCH (fromNode)-[{relationship}]->(toNode) "
Since
{relationship}is a map with only a single property, you can do one of the following. Let's say the map is{x: 123}.You can just use the property from the map in your
MATCHpattern:Instead of using a map, you can just pass the value of
xas a parameter. In this example, I assume that you have replaced{relationship}with{x}:Note: the recent versions of neo4j have deprecated the
{x}syntax, and now prefer$x.