A way to mimic a composite constraint


the below is not exactly what i'm dealing with but gives an accurate picture.

So in neo4j i want to have nodes that represent 3D points. Let's say i'm importing them from a csv file which has loooots of them. I know that to speed up import, i can create a constraint. And I know how to do it using a single property, but here bacause i have 3D points, it would have to be a composite constraint (combining all 3 spatial coordinates). I'm using a community neo4j, so a composite constraint feature is not available.

i came up with the below - glue together the coordinates to create a unique code. but i wonder if there's anything more efficient, smarter etc ?

LOAD CSV WITH HEADERS FROM 'file:///my3DPoints.csv' AS row
MERGE (p:3DPoint { x:toInteger(row.x), y:toInteger(row.y), z:toInteger(row.z), code:(row.x + ',' + row.y + ',' + row.z) }))

so any ways/tricks/hacks/workarounds to achieve what i want ? any help appreciated.


Hello @lukasz.mika :slight_smile:

Why don't you use the Spatial functions to store your 3D points?

Otherwise there are other possiblites:

Like this you could create unique constraint on the uuid or the hash.


Thanks for replying.

these spatial functions look cool and i would definitely use them. The thing is that the actual problem im' dealing with is a bit different... I model a 2D boxes and each one is defined by two 2D points. So as a result each neo4j node is composed of 4 integer values and i would like to create an index/constraint on that.

as for uuid solution, i gave it a brief read. But not sure if i understand it. As there doesn't seem to be any mapping between node properties and the uuid generated. I might just keep reading on that.

hash property looks good and i might go for that.

Thanks again!