Top
Enterprise Postgres 17 SP1 Knowledge DataManagement FeatureUser's Guide

4.6 Searching Graph

Graph searches are performed using Cypher queries. Cypher queries are specified as strings as arguments to the cypher function, which is an SQL function.

For more information about Cypher queries, refer to the Apache AGE documentation.

Example) Graph search

SELECT * FROM cypher('new_graph', $$
 MATCH (:Person {name: 'Daedalus'})-[:FATHER_OF]->(person)
 WITH person.name AS name ORDER BY person.name RETURN name
 $$) AS (v agtype);
    v
----------
 "Icarus"
(1 row)

Graph searches allow you to retrieve specific property values or sets of properties for nodes or edges that match a condition. Properties are returned in agType data type added by the graph management feature, which is compatible with JSON types. Graph searches are closed to cypher functions, but the retrieved values ​​can also be combined with searches of other tables in the database.

Example) Combination

SELECT (x::json->'properties')->'name' FROM cypher('new_graph', $$
MATCH (x)
RETURN x $$) AS (x agtype);
  ?column?
------------
 "Daedalus"
 "Icarus"
(2 row)