Reputation: 67
I am using Neo4J from a Java Servlet. I have code that initializes the database, creates some indexes, and declares some UniqueNodeFactories.
When I restart the Servlet, how do I check whether an index has already been created and get a reference to it if it has? How do I do the same thing with UniqueNodeFactories?
Upvotes: 0
Views: 68
Reputation: 19373
To get a reference to an index, you can use:
IndexManager index = graphDb.index();
Index<Node> actors = index.forNodes( "actors" );
forNodes will create the index if it does not already exist.
Instead, if you just want to check existence of an index, you can use:
index.existsForNodes( "actors" );
I believe the same applies to the UniqueNodeFactory (it is returned or created if it does not exist):
UniqueFactory<Node> factory = new UniqueFactory.UniqueNodeFactory( graphDb, "actors" )
Upvotes: 1