apache age with

apache

In Apache AGE (Approximate Graph Engine), the WITH clause is used to specify a set of intermediate results that can be used in subsequent clauses of a query. It is similar to the WITH clause in Cypher, the query language used by Neo4j.

Here is an example of how you might use the WITH clause in an AGE query:

MATCH (n:Person)-[:FRIEND]->(m:Person)
WHERE n.name = 'Alice' AND m.name = 'Bob'
WITH n, m
MATCH (n)-[:FRIEND]->(x:Person)<-[:FRIEND]-(m)
RETURN x

In this example, the MATCH and WHERE clauses are used to find two nodes with the names Alice and Bob that are connected by an edge labeled FRIEND. The WITH clause then specifies that the resulting nodes should be saved as intermediate results. The second MATCH clause then uses those intermediate results to find other nodes that are friends with both Alice and Bob. Finally, the RETURN clause specifies that the resulting nodes should be returned.

The WITH clause is useful for breaking up a complex query into smaller pieces and making the query more readable. It allows you to use intermediate results from one part of the query in another part of the query, without having to repeat the full query.