Home » Php » php – Can I create a node in neo4j with specified id?

php – Can I create a node in neo4j with specified id?

Posted by: admin July 12, 2020 Leave a comment


I want to hold relationships in neo4j but (maybe, I’ve not decided yet) to keep the objects in different DB (sort of Redis).
And if to do so, it would be good to sync IDs in storage db and in neo4j.
So, can I create a node in neo4j passing the ID to it?

project in PHP and accessing neo4j via REST API.

How to&Answers:

You normally can’t, only if you use the BatchImporter, http://docs.neo4j.org/chunked/snapshot/indexing-batchinsert.html, you can specify the IDs to use.


Otherwise it is sensible to use external id’s as node properties and index the nodes on those properties. So you have bi-directional resolutions of your external id’s.

The indexing can also be done using the auto-indexer, so it happens automatically on node creation, update and removal.

You might also look into Neo4jPHP as a library to access Neo4j’s REST API.