Question

I have been reading through the documentation for neo4j and it's components and have yet to come across functionality that lets me query the total number of primitives (nodes, relationships, and properties) in the graph. Does this functionality exist somewhere or am I going to have to write code that traverses the entire graph counting as it goes?

Was it helpful?

Solution

Thanks for the question! I'm on the Neo4j team, and we currently have commercial tools which report this kind of information. However, an extension of the API is scheduled for the next open source version. For the time being you can use the following non-official API:

EmbeddedNeo.getConfig().getNeoModule().getNodeManager().getNumberOfIdsInUse(Class)

where the class would be Node.class, Relationship.class or PropertyStore.class.

OTHER TIPS

This worked for me:

import org.neo4j.kernel.impl.nioneo.store.PropertyStore

graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(Node.class);
graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(Relationship.class);
graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(PropertyStore.class)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top