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

Read the 2019 State of Database DevOps Report for the very latest insights

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!

Read the 2019 State of Database DevOps Report for latest insights into DevOps adoption among SQL Server professionals, and the benefits and challenges of including the database in DevOps initiatives

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 }}