I am using AWS Neptune and using python with neo4j to query the database. I am having difficult time to fetch the completely hierarchy by a node id.
I want the all children and sub children which are directly and in-directly connected to a particular node.
Node Properties:
(~id
, 'entity_name', 'entity_type', ~label
)
Edge Properties:
(~id
, ~label
, 'journey_id')
I have tried multiple queries, but I am getting timeout after 10 minutes since my aws neptune timeout is 10 minutes.
MATCH (source)<-[relationship*]-(target)
WHERE source.`~id` = '{entity_id}'
RETURN source, relationship, target
MATCH (source)<-[relationship*]-(target)
WHERE source.`~id` = '{entity_id}'
RETURN COLLECT(DISTINCT target)
MATCH (source)<-[relationship*]-(target)
WHERE source.`~id` = '{entity_id}'
RETURN COLLECT(DISTINCT [ID(startNode(relationship)), TYPE(relationship), ID(endNode(relationship))])
MATCH p=(source)<-[relationship*]-(target)
WHERE source.`~id` = '{entity_id}'
WITH p, source, target, nodes(p) AS n, relationships(p) AS r
UNWIND n AS node
WITH source, target, COLLECT(DISTINCT node) AS NODES, r
UNWIND r AS rel
WITH source, target, nodes, COLLECT(DISTINCT rel) as rels
RETURN source, target, nodes, rels
MATCH (source)<-[relationship*]-(target)
WHERE source.`~id` = '{entity_id}'
AND EXISTS( (source)<-[]-() )
RETURN source
MATCH p=(source {`~id`: '{entity_id}'})-[relationship*]-(target)
WITH DISTINCT p as path, source, target
return source, relationships(path) as rels, target
I have tired all the above queries but not efficient enough. It's working fine if I limit the hierarchy to some level but in my scenario I want the completely hierarchy.
can anyone help with it?