Results 1 to 3 of 3

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

  1. #1
    Join Date
    Jul 2012
    Posts
    18

    Default 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. #2

    Default

    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. #3
    Join Date
    May 2012
    Posts
    107

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •