neo4jcypherneo4j-browser

How to reference ID as param in Neo4J


I have a node with internal id 35831. I run the following code in the Neo4J Browser:

:params "id": 35831

match (t) where id(t) = $id return t

Expected result: the node

Actual result: (no changes, no records)

Is this expected behavior or should I provide info about my neo4j version?


Solution

  • In the Neo4j browser, when you set a numerical parameter its type is a float. See the result when you type :params "id": 35831, you should see 35831.0 as a value.

    And that's why your query returns nothing...

    But if you use this query MATCH (n) WHERE id(n)=toInteger($id) RETURN n it works !

    FYI, this is only true for the browser, if you use the cypher-shell, it will works like you want :

    neo4j> :param id 5
    neo4j> MATCH (n) WHERE id(n)=$id RETURN n;