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

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

    Hi,

    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 org.springframework.data.neo4j.support.query.Cyphe rQueryEngine.parseAndExecuteQuery(CypherQueryEngin e.java:67)
    at org.springframework.data.neo4j.support.query.Cyphe rQueryEngine.query(CypherQueryEngine.java:53)
    ... 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.

    Comment


    • #3
      hsherlock, vmarcinko,

      Parameterised relationship types are indeed not supported. Details of what is supported is here: http://docs.neo4j.org/chunked/milest...arameters.html

      Regards,

      Lasse

      Comment

      Working...
      X