【问题标题】:Index and orientdb索引和orientdb
【发布时间】:2016-11-07 10:27:07
【问题描述】:

我在 orientdb 中创建了一个包含图的所有边的索引。进行查询:

select from index: Where unique_edge key = # 9: 1

结果在我得到的网络控制台中

OCompositeKey {keys = [# 9: 1, # 9: 0]}
OCompositeKey {keys = [# 9: 1, # 12: 0]}

Java 控制台中的相同查询有

# 3: -1
# 3: -1

我需要得到边的顶点

# 9: 1, # 9: 0, # 12: 0.

有人可以帮助我吗?

【问题讨论】:

  • 你用的是哪个版本?
  • 您好,您可以发布您的架构吗?提前谢谢

标签: indexing orientdb


【解决方案1】:

你可以使用

select both() from #9:1

因为你的索引不会提高速度。

希望对你有帮助。

【讨论】:

  • 谢谢,我如何分别获得两个顶点,即在两个查询中
  • 从 #9:1 中选择 in() 并从 #9:1 中选择 out()
【解决方案2】:

创建de索引

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());


}

【讨论】:

  • 你不应该创建属性 IN 和 OUT 因为 E 类已经存在。
  • 谢谢,但我做到了,但没有创建 in、out 属性,我出现了这个错误............无法创建名为“unique_edge”的索引类'E',因为类定义中没有字段'in'......
猜你喜欢
  • 2016-05-13
  • 2013-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-13
相关资源
最近更新 更多