我试图通过使用索引功能来获取顶点,但只获得NullPointerException。
以下是我的代码中的相关部分:
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();
调试时我可以看到rawGraph(Neo4j Graph)中的autoIndex启用了自动索引,其值正确。看看Tinkerpop - Graph,索引似乎是空的......
答案 0 :(得分:1)
看来,从现有的neo4j图中缓存现有索引存在一些问题。我使用的是1.1(core和neo4jgraph)的实际稳定版本。所以我猜它将在另一个版本中修复。