简体   繁体   中英

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?

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;

You can use following syntax to set a parameter in the browser:

:param id => 1

....

{
  "id": 1
}

Then your query will work just fine:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM