Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Neo4j Browser: Expected Entity ID to Be an Integral Value

DZone's Guide to

Neo4j Browser: Expected Entity ID to Be an Integral Value

Here's how I solved an error that I came across while writing a Cypher query that said Expected entity id to be an integral value.

· Database Zone ·
Free Resource

Databases are better when they can run themselves. CockroachDB is a SQL database that automates scaling and recovery. Check it out here.

I came across an interesting error while writing a Cypher query that used parameters in the Neo4j browser which I thought I should document for future me.

We'll start with a graph that has 1,000 people:

unwind range(0,1000) AS id
create (:Person {id: id})

Now, we'll try to retrieve some of those people via a parameter lookup:

match (p:Person) where p.id in {ids}
return p

╒════════╕
│"p"     │
╞════════╡
│{"id":0}│
└────────┘

All good so far. Now, what about if we try to look them up by their internal node ID instead?

match (p:Person) where id(p) in {ids}
return p

Neo.ClientError.Statement.TypeError
Expected entity id to be an integral value

Hmm, that was unexpected. It turns out that to get this query to work, we need to cast each of the integer values in the {ids} array to a 64-bit integer using the function:

match (p:Person) where id(p) in [id in {ids} | toInteger(id)]
return p

╒════════╕
│"p"     │
╞════════╡
│{"id":0}│
└────────┘

Success!

Databases should be easy to deploy, easy to use, and easy to scale. If you agree, you should check out CockroachDB, a scalable SQL database built for businesses of every size. Check it out here. 

Topics:
database ,tutorial ,cypher ,neo4j

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}