I'm facing an issue to create edge between vertices, where one of the vertex is getting by using orient SQL function,
below is requirement
let say I have 3 vertices vertex1(@rid: #9:0), vertex2(@rid: #10:0), vertex3(@rid: #11:0), and edge beteween vertex1 and vertex 2 is already exist. Now I need to get vertex1 from vertex2 and create edges between vertex1 and vertex3
class
Exception:
java.lang.IllegalArgumentException: Cluster segment #-2 does not exist in database 'test' at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.checkClusterSegmentIndexRange(OAbstractPaginatedStorage.java:4627) at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.getClusterById(OAbstractPaginatedStorage.java:3013) at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.readRecord(OAbstractPaginatedStorage.java:1404) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx$SimpleRecordReader.readRecord(ODatabaseDocumentTx.java:3411) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeReadRecord(ODatabaseDocumentTx.java:2022) at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:187) at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:162) at com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:291) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:1739) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:103) at com.orientechnologies.orient.core.id.ORecordId.getRecord(ORecordId.java:329) at com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy.begin(OTransactionOptimisticProxy.java:176) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.begin(ODatabaseDocumentTx.java:1881) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.begin(ODatabaseDocumentTx.java:103) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.commit(ONetworkProtocolBinary.java:1426) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:668) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:398) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:217) at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:82)
答案 0 :(得分:1)
最后,我的代码使用了UNWIND函数
String query = "select @rid ad base, inE('child').outV() as source from V where name='vertex3' UNWIND source";
我们也可以使用EXPAND函数
String query = "select @rid ad base, EXPAND(inE('child').outV()) as source from V where name='vertex3'";
但它会忽略多个预测
以下链接帮助我解决了这个问题
OrientDB SELECT and subqueries
https://github.com/orientechnologies/orientdb/issues/3755
http://orientdb.com/docs/last/SQL-Query.html#unwinding
谢谢,