aggregate

Aggregate all objects into a collection at a particular point in a graph traversal.

Synopsis

aggregate('variable\_name')

Description

The aggregate() step is a sideEffect. A vertex is added from a traversal g using addV. A previously created vertex label must be specified.

Examples

Return a collection of all the people that John Doe knows as an aggregate:

g.V().has('person', 'name', 'John Doe').
   out('knows').aggregate('x')

Return all the friends of John Doe’s friends, including those that are friends of John Doe:

 g.V().has('person', 'name', 'John Doe').
   out('knows').aggregate('x').
   in('knows').out('knows').valueMap('name', 'gender')

Find all the friends of John Doe’s friends that are not friends of John Doe:

g.V().has('person', 'name', 'John Doe').
   out('knows').aggregate('x').
   in('knows').out('knows').
   where(without('x'))

Note the use of the aggregate('x') in the later step where(without('x')) that is used to exclude John Doe’s friends using the aggregate assigned to the variable x.

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