I cannot solve this in osql, but I can provide some information that is 
hopefully helpful.


1) how to solve in gremlin


g.v("12:0").out.out.path{it.getIdentity()}

relevant gremlin documentation is:
http://gremlindocs.com/#transform/path


g.v("12:0").out('edge').out('edge').path{it.getIdentity()}

will constrain going out to edges with label 'edge'.

2) related orientdb documentation:


a) there are several shortest path functions, and functions for getting all 
traversed elements
http://www.orientechnologies.com/docs/last/orientdb.wiki/SQL-Functions.html#dijkstra


b) there is a "$path" context variable, I haven't managed to get it to work 
tho...
http://www.orientechnologies.com/docs/last/orientdb.wiki/SQL-Traverse.html

c) in this post had a similar question
https://groups.google.com/forum/#!searchin/orient-database/path|sort:date/orient-database/bK-T3xt0fPo/UabnbtscHEgJ

the answer was:

The TRAVERSE command is not designed to find all paths between nodes. To 
> prevent going into a loop it does not traverse nodes that has already been 
> handled.
> To find all paths between vertexes you can use gremlin query or write your 
> own function.
> Best regards,
> Artem Orobets
> Orient Technologies
> the Company behind OrientDB


hope this is helpful!


On Thursday, March 19, 2015 at 8:43:28 AM UTC-7, Mihai Pricop wrote:
>
> I want to query a vertex in OrientDB graph database to get the second 
> level vertices, keeping the in between vertex id.
>
> The relationship would be represented as such:
>
> User <--edge--> User <--edge--> User
> (1)             (2)             (3)
>
> For User 1, I want to get all User 3 (distance of 2 edges), but I want to 
> keep as a result all User 2 rids. The direction isn't important (will use 
> both() method to traverse)
>
> An example:
>
> #10:1 <--edge--> #10:2
> #10:1 <--edge--> #10:3
> #10:2 <--edge--> #10:4
> #10:2 <--edge--> #10:5
> #10:3 <--edge--> #10:6
>
> For the example above, the query for #10:1 should return: (don't know how 
> to represent this any better, but the query should return the object from 
> the class User AND the rid from the intermediate User)
>
> User(#10:4), #10:2
> User(#10:5), #10:2
> User(#10:6), #10:3
>
> The query to find the vertices from the second level would look like: select 
> expend(both('edge').both('edge')) from #10:2 (of course the query can be 
> optimized with set function and other conditions in case of inter-relations 
> of the output users). To this output, I would like to see an additional 
> field (property / column, whatever you want to call it) where I can see the 
> in between vertex of this kind of relationship.
>
> Hope somebody can help me with this, tell me if you need more information, 
> or if you did not understand something. Thank you.
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to