我在orientdb中创建了一个带有图形所有边的索引。进行查询:
select from index: Where unique_edge key = # 9: 1
因为我得到了Web控制台
OCompositeKey {keys = [# 9: 1, # 9: 0]}
OCompositeKey {keys = [# 9: 1, # 12: 0]}
和java控制台中的相同查询
# 3: -1
# 3: -1
我需要获取边缘的顶点
# 9: 1, # 9: 0, # 12: 0.
有人可以帮助我吗?
答案 0 :(得分:1)
您可以使用
select both() from #9:1
因为你的索引不会提高速度。
希望它有所帮助。
答案 1 :(得分:-1)
创建de index
OCommandSQL declareIn= new OCommandSQL();
declareIn.setText("CREATE PROPERTY E.in LINK");
OCommandSQL declareOut= new OCommandSQL();
declareOut.setText("CREATE PROPERTY E.out LINK");
OCommandSQL createIndexUniqueEdge= new OCommandSQL();
createIndexUniqueEdge.setText("CREATE INDEX unique_edge ON E (in, out) UNIQUE");
orientDBGraph.command(declareIn).execute();
orientDBGraph.command(declareOut).execute();
orientDBGraph.command(createIndexUniqueEdge).execute();
System.out.println(createIndexUniqueEdge.getText());
String query10 = "select from index:unique_edge where key=#9:1";
Iterable<OrientVertex> res10 = orientDBGraph.command(new OCommandSQL(query10)).execute();
while(res10.iterator().hasNext()){
OrientVertex source = res10.iterator().next();
System.out.println(source.getId());
}