4
我想知道当需要根据某些节点类型或字段设置多个indecies时,什么是更好的方法。 例如,假设我想要一张学生图,并希望通过他们的学校和身份证编制索引。在Neo4j中建立索引
按我的理解,我可以有这样每所学校的指标:
// add student
Index<Node> index = this.graphDb.index().forNodes(schoolName);
Node node = this.graphDb.createNode();
node.setProperty("id", studentId);
index.add(node, "id", studentId);
// get student
Index<Node> index = this.graphDb.index().forNodes(schoolName);
Node node = index.get("id", studentId).getSingle();
我能,另一方面采用一个指标,这样做:
// add student
Index<Node> index = this.graphDb.index().forNodes("schools");
Node node = this.graphDb.createNode();
node.setProperty("id", studentId);
index.add(node, schoolName + ":id", studentId);
// get student
Index<Node> index = this.graphDb.index().forNodes("schools");
Node node = index.get(schoolName + ":id", studentId).getSingle();
什么是更好的方法? 对彼此有什么好处? 当涉及到很多节点时,尤其是性能明智或存储方面。
谢谢
哦,哇,一个控制台!谢谢你,没有意识到它的存在。我对此很新,我会检查一下。 – 2012-04-27 08:57:03