In Neo4J how do I get the largest node id in the graph?
I'm running a script that iterates through all the nodes. Initially, I thought the maximum node id would correspond to the total number of nodes in the graph which I retrieved by this Cypher query over REST:
START n=node(*) RETURN count(n)
However, as I iterate through each number, I see that some nodes at certain ids just don't exist. So, this means my maximum id node is a number larger than the total number of nodes. Any idea how I can retrieve this number? I strongly prefer Cypher or Rest.
You can get this number through JMX, see http://docs.neo4j.org/chunked/1.4.2/operations-monitoring.html or with Java via
Neo4jManager manager = new Neo4jManager( graphDb.getManagementBean( Kernel.class ) ); long nodeIDsInUse = manager.getPrimitivesBean.getNumberOfNodeIdsInUse();
This is also exposed to the Webadmin JMX endpoint via REST starting at