Leave a comment

APOC to the rescue #1

Picture yourself, querying on a text property, looking for duplicates and BOOM you see they not only have the same text but also the same Identifier !!!

Your brain screams “OMG I have nodes with the same identifier ! How can that be !”

Your start to wonder if all the confidence you put on Neo is misplaced.
A true trial of faith.

Doubt not.
This can happen, even though you created a fine constraint on the property, even though Neo is written by fine brains and IDs is MVP level for a DB.
You dont believe it ?

The reason it can happen is data type.

123456 and ‘123456’ are not the same.
So if you (like me) forgot to convert from string to integer in your LOAD CSV script, thats what happens.

To solve this and identify the nodes you just created, APOC can help.
What can APOC not do ?

There is a function apoc.meta.cypher.type(property) returning STRING where the property is stored as a String.


MATCH (n:Label)
WHERE apoc.meta.cypher.type(n.property) = 'STRING'
RETURN count(s)

That code will give you an idea of the width of the mistake.

The Cypher code to solve this is coming next 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: