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

RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.  

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!

Aggregations provide vital intelligence to the success of a business. Crush the challenge of providing real time aggregations for daily, weekly, and monthly totals without having to tie up your servers.

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