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

Running out of memory? Learn how Redis Enterprise enables large dataset analysis with the highest throughput and lowest latency while reducing costs over 75%! 

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!

Running out of memory? Never run out of memory with Redis Enterprise databaseStart your free trial today.

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