##### Neo4j Embedded Examples

- Introduction
- Neo4j JavaDocs
- Wiki
- Source Repository
- Downloads

##### Examples

- Basic usage
- Basic index usage
- Integrated indexing
- Traversal
- Ordered path traversal
- Domain entities
- Social network
- Graph algorithms
- Management features

##### Test examples

- Base test

##### Examples full source code

- Example code
- Example test code

##### Project Documentation

- Project Information
- Project Reports

## Integrated index usage

This example is similar to the basic indexing example, but uses the integrated indexing API.

Take a look at the differences. Here's creating an index:

            graphDb = new EmbeddedGraphDatabase( DB_PATH );
            nodeIndex = graphDb.index().forNodes( INDEX_NAME );
            registerShutdownHook();

A new node index is created by requesting the named index from the `index()` singleton associated with a `GraphDatabaseService`. If the index does not yet exist, it will be created.

Indexing a node's property is easy:

            Node node = graphDb.createNode();
            node.setProperty( USERNAME_KEY, username );
            nodeIndex.add( node, USERNAME_KEY, username );

The nicest improvement is that the index does not require a seperate shutdown. Just shutdown the `GraphDatabaseService`:

            graphDb.shutdown();

Full source code: UsingIntegratedIndex