Discussion:
[orientdb] Using gremlin to get all the child vertex of a class.
smita padhy
2018-09-10 05:58:41 UTC
Permalink
Hi All,
I have a db model which follows OrientDB oops concept. I am using gremlin
to query the db. If i use following code i am able to get all the children
of the class test.


OrientDB orientDB = new
OrientDB("remote:localhost","root","root",OrientDBConfig.defaultConfig());
ODatabasePool pool = new ODatabasePool(orientDB,"OOPSDemo","root","root");
try (ODatabaseSession db = pool.acquire()) {
ORecordIteratorClass<ODocument> cls = db.browseClass("test");
Iterator<ODocument> itr = cls.iterator();
while(itr.hasNext())
{
ODocument v = itr.next();
System.out.println("class name"+v.getClassName());
System.out.println("id"+v.getIdentity());
System.out.println("json"+v.toJSON());
}

}
pool.close();
orientDB.close();

But when i use gremlin i am unable to get all the children -

List<Vertex> edgeList = g.traversal().V().hasLabel("test").bothV().toList();

i just have vertex and no edges. I am trying to do a POC to see if we can
achieve the model designed in neo4j using orient db oops.

Please let me know if i am missing something in gremlin.


Regards
Smita
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Fabrice Martellucci
2018-09-10 09:14:27 UTC
Permalink
hey,

im beginner me too but i dont see the bothE

see doc :
https://orientdb.com/docs/3.0.x/sql/SQL-Traverse.html

Vertex to all edges Using bothE()

no ?
Post by smita padhy
Hi All,
I have a db model which follows OrientDB oops concept. I am using
gremlin to query the db. If i use following code i am able to get all the
children of the class test.
OrientDB orientDB = new
OrientDB("remote:localhost","root","root",OrientDBConfig.defaultConfig());
ODatabasePool pool = new ODatabasePool(orientDB,"OOPSDemo","root","root");
try (ODatabaseSession db = pool.acquire()) {
ORecordIteratorClass<ODocument> cls = db.browseClass("test");
Iterator<ODocument> itr = cls.iterator();
while(itr.hasNext())
{
ODocument v = itr.next();
System.out.println("class name"+v.getClassName());
System.out.println("id"+v.getIdentity());
System.out.println("json"+v.toJSON());
}
}
pool.close();
orientDB.close();
But when i use gremlin i am unable to get all the children -
List<Vertex> edgeList =
g.traversal().V().hasLabel("test").bothV().toList();
i just have vertex and no edges. I am trying to do a POC to see if we can
achieve the model designed in neo4j using orient db oops.
Please let me know if i am missing something in gremlin.
Regards
Smita
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...