Skip to content

Neo4j Implementation

okram edited this page Feb 16, 2012 · 20 revisions

<dependency>
   <groupId>com.tinkerpop.blueprints</groupId>
   <artifactId>blueprints-neo4j-graph</artifactId>
   <version>??</version>
</dependency>
Graph graph = new Neo4jGraph("/tmp/neo4j");

Neo Technology are the developers of the Neo4j graph database. Neo4j natively supports the property graph data model. However, there are a few peculiarities in Neo4j that make it not completely faithful to the property graph model as specified by Blueprints. These are itemized below.

  1. No user defined element identifiers: Neo4j is the gatekeeper and creator of vertex and edge identifiers. Thus, when creating a new vertex or edge, the provided object identifier is ignored.
  2. Only primitive property values: Neo4j requires that the value objects in the property map of an element be Java primitives, java.lang.Strings, or arrays of primitives and java.lang.Strings.

Indices with Neo4jGraph

It is possible to parameterize the indices created through Blueprints.

graph.createAutomaticIndex("myIdx", Vertex.class, null, new Parameter("analyzer", LowerCaseKeywordAnalyzer.class.getName()));
Vertex a = graph.addVertex(null);
a.setProperty("name", "marko");
Iterator itty = graph.getIndex("myIdx", Vertex.class).get("name", Neo4jTokens.QUERY_HEADER + "*rko").iterator();
assertEquals(itty.next(), a);