0

This question has an answer for how to find nodes which don't have outgoing edges on neo4j and cypher:

MATCH ()-[:A]->(n) WHERE NOT (n)-->() RETURN n

However, this does not work on Apache AGE:

select *
from cypher('graph_name', $$
 MATCH ()-[:A]->(n) WHERE NOT (n)-->() RETURN n
$$) as (n agtype)

which gives:

ERROR: syntax error at or near ">"
LINE 3: MATCH ()-[:A]->(n) WHERE NOT (n)-->() RETURN n
 ^ 
SQL state: 42601
Character: 69

How can I accomplish the same query in Apache AGE?

I'm using the latest version of Apache AGE (1.5.0) at time of posting.

I've tried variations for the NOT clause such as

  • (n)-[]->()
  • (n)-[r]->()
  • (n)-[*]->()

but none have worked.

asked Jan 25, 2024 at 8:24

1 Answer 1

0

The equivalent query is:

select *
from cypher('graph_name', $$
 match ()-[:A]->(n)
 where not exists((n)-[]->())
 return distinct n
$$) as (n agtype)

The difference is that this part of the query:

WHERE NOT (n)-->()
RETURN n

is replaced with:

WHERE NOT EXISTS((n)-[]->())
RETURN DISTINCT n
answered Jan 25, 2024 at 8:38
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.