Gerd
Gerd

Reputation: 89

How to use Tinkerpops IndexableGraph - Features in a Neo4j - Graph?

I am trying to get a vertex by using indexing-features, but only getting a NullPointerException.

Here are the relevant parts from my code:

Map<String, String> config = new HashMap<String, String>();
config.put( Config.NODE_KEYS_INDEXABLE, "type, categoryName" );
config.put( Config.NODE_AUTO_INDEXING, "true" );

GraphDatabaseService neoGraphDbService = new EmbeddedGraphDatabase(dblocation,config);
Graph tiGraphDb = new Neo4jGraph(neoGraphDbService, false);

...
//This category is saved correctly
ICategory mashineCategory = manager.frame(tiGraphDb.addVertex(null),
            ICategory.class);

//this Property should be indexable...
mashineCategory.setCategoryName("mashineCategory");
mashineCategory.setType(NodeTypes.CATEGORY.toString());
...

//Here I´m getting a NullPointerException
String catName = "mashineCategory";
Vertex foundMashineCategory = ((IndexableGraph)tiGraphDb).getIndex(Index.VERTICES, Vertex.class).get("categoryName", catName).iterator().next();

when debugging i can see that the autoIndex from the rawGraph (Neo4j Graph) has its autoindex enabled, with its correct values. Looking at the Tinkerpop - Graph, the Index seems to be empty...

Upvotes: 0

Views: 500

Answers (1)

Gerd
Gerd

Reputation: 89

It seems, there are some issues with caching existing indices from an existing neo4j-graph. I was using the actual stable version of 1.1 (core and neo4jgraph). So I guess it will be fixed in a further version.

Upvotes: 1

Related Questions