Recursive Traversals

Recursive traversals allow iterative processing over traversal paths. Prior to trying out branching traversals shown here, you must create the data as described in Simple Traversals.

This recursive traversal example returns the names of vertices that are two outgoing steps from the author vertex named Julia Child using the times(2) step. Books, meals, and ingredients are returned by this query.

g.V().has('name','Julia Child').repeat(out()).times(2).valueMap()

The output for this traversal lists each result:

==>{name=[onion]}
==>{name=[beef]}
==>{name=[mashed garlic]}
==>{name=[butter]}
==>{name=[tomato paste]}
==>{name=[JuliaDinner], calories=[900], timestamp=[2016-01-14T00:00:00Z]}
==>{year=[1961], name=[The Art of French Cooking, Vol. 1]}
==>{name=[Saturday Feast], calories=[1000], timestamp=[2015-11-30T00:00:00Z]}
==>{name=[olive oil]}
==>{name=[green beans]}
==>{name=[tuna]}
==>{name=[hard-boiled egg]}
==>{name=[tomato]}
==>{name=[JuliaDinner], calories=[900], timestamp=[2016-01-14T00:00:00Z]}
==>{year=[1961], name=[The Art of French Cooking, Vol. 1]}
==>{name=[olive oil]}
==>{name=[yellow onion]}
==>{name=[zucchini]}
==>{name=[mashed garlic]}
==>{name=[eggplant]}

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com