DEV Community

Muhammad Muneeb Ur Rehman
Muhammad Muneeb Ur Rehman

Posted on

Read Vertices (Nodes) in Apache AGE

We can retrieve the Nodes from our Graph in Apache AGE by different ways depending on our need.

Here is the General form of the Query:

SELECT * FROM cypher('graph_name', $$
MATCH (v)
RETURN v
$$) as (v agtype);

Explanation:
Firstly, we select the Graph from which we want to get Nodes/ Vertices by SELECT * FROM cypher('graph_name'. Secondly, we match the vertices MATCH (v). Lastly, we return RETURN v. We return result as $$) as (v agtype);.

Match with Label:
We can pass any condition in the MATCH() function. For instance, we can get all nodes of particular Label.

SELECT * FROM cypher('graph_name', $$
MATCH (v:LabelName)
RETURN v
$$) as (title agtype);

Match with Properties:
We can pass any condition in the MATCH() function for property of Node as well. For instance, we can get all nodes of particular Label having propertyName = AnyValue.

SELECT * FROM cypher('graph_name', $$
MATCH (v:LabelName{propertyName = AnyValue})
RETURN v
$$) as (title agtype);

For more details visit: https://age.apache.org/overview/

AGE Github Link: https://github.com/apache/age

AGE Viewer Github Link: https://github.com/apache/age-viewer

Top comments (0)