Announcement Announcement Module
No announcement yet.
Are parameters supported in Cypher MATCH clause like -[:{type}]->? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Are parameters supported in Cypher MATCH clause like -[:{type}]->?


    I think I found a problem - it looks that Cypher cannot substitute relationship type in the MATCH clause with external parameters passed in format {param} like the following:

    START n1=node({self}) MATCH n1-[rel:{type}]->n2 RETURN n2

    The following code which refers to {type} parameter generates an exception:

    Hashtable<String, Object> params = new Hashtable<String, Object>();
    params.put("res", nodeId);
    params.put("type", type);
    String cypherQuery = "START n=node({res}) MATCH n-[rel:{type}]->result RETURN rel";
    Result<Map<String, Object>> rows = template.query(cypherQuery, params);

    the exception:
    Error executing statement START n=node({res}) MATCH n-[rel:{type}]->result RETURN rel; nested exception is string matching regex ``(``|[^`])*`' expected but `{' found

    at rQueryEngine.parseAndExecuteQuery(CypherQueryEngin
    at rQueryEngine.query(
    ... 39 more
    Caused by: string matching regex ``(``|[^`])*`' expected but `{' found

    Is it a bug or I am doing something wrong?

  • #2
    I'm no expert in this, but I remember I found somewhere in Neo4j server's documentation (not Spring data Neo4j docs) explanation where parametrizing is exactly allowed (not anywhere in query), so I assume that's your problem here.


    • #3
      hsherlock, vmarcinko,

      Parameterised relationship types are indeed not supported. Details of what is supported is here: