Discussion:
[orientdb] how to perform deep traversal
Suraj Shankar
2018-08-28 00:44:20 UTC
Permalink
HI All,
I have a graph as following :
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3

Now when i start at any of the leaf nodes and traverse using in nodes, i
get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i perform
this?
--
---
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.
Luigi Dell'Aquila
2018-08-28 07:36:58 UTC
Permalink
Hi Suraj,

how do you do the traversal? in SQL?

Thanks

Luigi


Il giorno mar 28 ago 2018 alle ore 09:31 Suraj Shankar <
Post by Suraj Shankar
HI All,
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3
Now when i start at any of the leaf nodes and traverse using in nodes, i
get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i perform
this?
--
---
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.
Suraj Shankar
2018-08-28 07:37:52 UTC
Permalink
Yes I am using the traverse command in sql

On Tue, Aug 28, 2018 at 12:37 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
Hi Suraj,
how do you do the traversal? in SQL?
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:31 Suraj Shankar <
Post by Suraj Shankar
HI All,
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3
Now when i start at any of the leaf nodes and traverse using in nodes, i
get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i
perform this?
--
---
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
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.
Suraj Shankar
2018-08-28 07:52:18 UTC
Permalink
My query is
traverse in(“contains”) from (select from nodesLeaf) strategy depth_first

On Tue, Aug 28, 2018 at 12:37 AM, Suraj Shankar <
Post by Suraj Shankar
Yes I am using the traverse command in sql
On Tue, Aug 28, 2018 at 12:37 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
Hi Suraj,
how do you do the traversal? in SQL?
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:31 Suraj Shankar <
Post by Suraj Shankar
HI All,
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3
Now when i start at any of the leaf nodes and traverse using in nodes, i
get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i
perform this?
--
---
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
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
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.
Luigi Dell'Aquila
2018-08-28 08:07:34 UTC
Permalink
hi Suraj,

The TRAVERSE statement automatically skips already traversed nodes, this is
why you don't see all the parents

You can use a MATCH with "while" condition instead:

MATCH
{class:nodesLeaf, as:a} <-contains- {as:b, while:(true), pathAlias:b_path}
RETURN b_path || b as thePath

I hope it helps

Thanks

Luigi

Il giorno mar 28 ago 2018 alle ore 09:52 Suraj Shankar <
Post by Suraj Shankar
My query is
traverse in(“contains”) from (select from nodesLeaf) strategy depth_first
On Tue, Aug 28, 2018 at 12:37 AM, Suraj Shankar <
Post by Suraj Shankar
Yes I am using the traverse command in sql
On Tue, Aug 28, 2018 at 12:37 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
Hi Suraj,
how do you do the traversal? in SQL?
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:31 Suraj Shankar <
Post by Suraj Shankar
HI All,
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3
Now when i start at any of the leaf nodes and traverse using in nodes,
i get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i
perform this?
--
---
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
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
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
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.
Suraj Shankar
2018-08-28 15:23:58 UTC
Permalink
Thanks a lot luigi. Just one more question adding to it. If I execute this
command from java code, how can I work with the results? Like the
individual nodes ? What will be the return type once I execute from
command() statement?

On Tue, Aug 28, 2018 at 1:07 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
hi Suraj,
The TRAVERSE statement automatically skips already traversed nodes, this
is why you don't see all the parents
MATCH
{class:nodesLeaf, as:a} <-contains- {as:b, while:(true),
pathAlias:b_path}
RETURN b_path || b as thePath
I hope it helps
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:52 Suraj Shankar <
Post by Suraj Shankar
My query is
traverse in(“contains”) from (select from nodesLeaf) strategy depth_first
On Tue, Aug 28, 2018 at 12:37 AM, Suraj Shankar <
Post by Suraj Shankar
Yes I am using the traverse command in sql
On Tue, Aug 28, 2018 at 12:37 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
Hi Suraj,
how do you do the traversal? in SQL?
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:31 Suraj Shankar <
Post by Suraj Shankar
HI All,
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3
Now when i start at any of the leaf nodes and traverse using in nodes,
i get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i
perform this?
--
---
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
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
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
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
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.
Luigi Dell'Aquila
2018-08-28 15:35:56 UTC
Permalink
Hi Suraj,

it will return an OElement per path, containing a property named "thePath"
that is a list of RIDs.
If you need expanded data, you can use nested projections
https://orientdb.com/docs/3.0.x/sql/SQL-Projections.html#nested-projections

Thanks

Luigi

Il giorno mar 28 ago 2018 alle ore 17:24 Suraj Shankar <
Post by Suraj Shankar
Thanks a lot luigi. Just one more question adding to it. If I execute this
command from java code, how can I work with the results? Like the
individual nodes ? What will be the return type once I execute from
command() statement?
On Tue, Aug 28, 2018 at 1:07 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
hi Suraj,
The TRAVERSE statement automatically skips already traversed nodes, this
is why you don't see all the parents
MATCH
{class:nodesLeaf, as:a} <-contains- {as:b, while:(true),
pathAlias:b_path}
RETURN b_path || b as thePath
I hope it helps
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:52 Suraj Shankar <
Post by Suraj Shankar
My query is
traverse in(“contains”) from (select from nodesLeaf) strategy depth_first
On Tue, Aug 28, 2018 at 12:37 AM, Suraj Shankar <
Post by Suraj Shankar
Yes I am using the traverse command in sql
On Tue, Aug 28, 2018 at 12:37 AM, Luigi Dell'Aquila <
Post by Luigi Dell'Aquila
Hi Suraj,
how do you do the traversal? in SQL?
Thanks
Luigi
Il giorno mar 28 ago 2018 alle ore 09:31 Suraj Shankar <
Post by Suraj Shankar
HI All,
1->1.1
1->1.2
2->2.1
2->2.2
2->2.3
Now when i start at any of the leaf nodes and traverse using in
nodes, i get
1.1,1
1.2
2.1,2
2.2
2.3
However i want the parent node as well in all the paths. How can i
perform this?
--
---
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,
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
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
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
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
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...