Skip to content

Neo4j Implementation

spmallette edited this page Mar 29, 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.String values, or arrays of primitives and java.lang.String values. Neo4jElement will also accept a Collection of like primitives or java.lang.String values and will convert those to the appropriate array type for storage in Neo4j.

Indices with Neo4jGraph

It is possible to parameterize the indices created through Blueprints. Learn more about the types of indices supported by Neo4j at this location.

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 + "MaRkO").iterator();
assertEquals(itty.next(), a);