프레임이있는 그래프로 고유 한 정점이 생성되도록하는 안전한 방법이 있습니까? 다음을 고려하십시오.프레임이있는 고유 정점
Node n = framedGraph.addVertex(1, Node.class);
Node m = framedGraph.addVertex(1, Node.class);
System.out.println(n.equals(framedGraph.getVertex(1, Node.class)));
System.out.println(m.equals(framedGraph.getVertex(1, Node.class)));
인쇄 true, false
.
Neo4j에서 제공하는 get or create unique node 기능 (이 경우 보조 그래프)과 유사한 기능을 찾고 있습니다.
비공식적으로 - 숫자가 아닌 ID를 사용하는 방법이 있습니까?
Node m = framedGraph.addVertex("http://example.org", Node.class);
System.out.println(n.equals(framedGraph.getVertex("http://example.org", Node.class)));
인쇄
감사합니다. ID 문제가 해결됩니다. 하지만 프레임 화 된 그래프에 정점을 추가하고 그 정점을 수동으로 생성 된 인덱스 ('index.put ("term", "foo1", n.asVertex());)에 추가하면 예외가 발생합니다 :'com .tinkerpop.blueprints.util.wrappers.id.IdVertex는 com.tinkerpop.blueprints.impls.neo4j.Neo4jElement'에 캐스팅 될 수 없습니다. 그걸 해결할 방법이 있니? – condit
'IdVertex'를 풀어야한다고 생각합니다. 'IdVertex' 인스턴스를 가져 와서 인덱스에 전달하기 전에'getBaseVertex'를 호출하십시오. http://www.tinkerpop.com/docs/javadocs/blueprints/2.4.0/com/tinkerpop/blueprints/util/wrappers/id/IdVertex.html#getBaseVertex() –
예 -'((IdVertex) n.asVertex()). getBaseVertex()'트릭을 수행합니다. 감사합니다. – condit