0

Hot to query using the auto generated id in the apache age graph database.

I want to get to know if it is edge id or a vertex id.

For example i have an id 844424930131970. I know its somewhere within graph. But I don't know if its id for a vertex or an id for edge

  • Please edit and clarify your question. Are you talking about using the graph oid to find out if something is an edge or a vertex? – moeed865 Feb 09 '23 at 07:08

1 Answers1

1

It would sort of depend on what you're trying to MATCH on to determine if it is a vertex or an edge. I don't think it is possible to match on an abstract object in the graph.

For a vertex:

postgresDB=# SELECT * FROM cypher('airroutes', $$
MATCH (n)
WHERE id(n) = 844424930131969
RETURN n $$)
AS (n agtype);
                                                                                                                                                                        n     
                                                                                                                                                                    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"id": 844424930131969, "label": "airport", "properties": {"id": "1", "lat": "33.63669968", "lon": "-84.42810059", "city": "Atlanta", "code": "ATL", "desc": "Hartsfield - Ja
ckson Atlanta International Airport", "elev": "1026", "icao": "KATL", "__id__": 1, "region": "US-GA", "country": "US", "longest": "12390", "runways": "5"}}::vertex

For an edge:

postgresDB=# SELECT * FROM cypher('airroutes', $$
MATCH ()-[e]-() 
WHERE id(e) = 1688849860263937
RETURN e $$)
AS (n agtype);
                                                                                             n                                                                                
             
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------
 {"id": 1688849860263937, "label": "route", "end_id": 844424930131971, "start_id": 844424930131969, "properties": {"dist": "809", "route_id": "3749", "end_vertex_type": "airp
ort"}}::edge
 {"id": 1688849860263937, "label": "route", "end_id": 844424930131971, "start_id": 844424930131969, "properties": {"dist": "809", "route_id": "3749", "end_vertex_type": "airp
ort"}}::edge
(2 rows)
Taylor Riggan
  • 1,963
  • 6
  • 12