[Neo] Newbie Q: How to load a previously created database?

Emil Eifrem emil at neotechnology.com
Fri May 29 17:53:40 CEST 2009

n Fri, May 29, 2009 at 16:27,  <orla.spillane at sunlife.com> wrote:
> Hi,
> I am new to Neo4J and relatively new to Java and have recently downloaded
> and ran a few Neo4j examples (i.e. Hello World and Matrix).
> In these examples the main() method creates the nodes and relationships of
> the graph. I assumed these would persist to disk automatically once the
> transaction was complete or the database was shutdown but if I change the
> code to assume these nodes exist and run it again, it can't find them.
> How do I load a previously created database?

Hi Orla,

If you commit the transaction (by flagging it successful through
tx.success() before you tx.finish()) then the data is definitely
persisted to disk. There are three ways you can find it:

   1) Make sure all your nodes are connected (indirectly) to the
reference node. Then go neoService.getReferenceNode() and traverse
from there.

   2) Index your nodes using an IndexService like LuceneIndexService.
The IndexService would be responsible for maintaining the mapping from
a property like name="Orla" to a specific node (or more).

   3) Remember the node ids in some secondary persistent storage and
look up the nodes directly through neoService.getNodeById().

I think the easiest way for you is to download the latest apoc release
(see front page of http://neo4j.org). It ships with a number of basic
examples. For example, look at the

Hope that helps!


Emil Eifrém, CEO [emil at neotechnology.com]
Neo Technology, www.neotechnology.com
Cell: +46 733 462 271 | US: 206 403 8808

More information about the User mailing list