Hello,
I'm trying to get all the related nodes starting from the specific one. I want to filter by properties stored in the nodes and relationships.
I started with the cypher
syntax, but has been blocked by the performance and finally switched to the apoc
.
My initial apoc
query was like that:
MATCH (p: MyFirstLabel {id: 'some-id'})
CALL apoc.path.subgraphAll(p, {minLevel: 0}) yield nodes, relationships
Then, I wanted to add the logic to get only nodes that has relationships created in the certain time period. I was able to write something like this one:
MATCH (p: MyFirstLabel {id: 'some-id'})
CALL apoc.path.subgraphAll(p, {minLevel: 0}) yield nodes, relationships
MATCH (start_node) - [relation] - (end_node)
WHERE
id(relation) IN [r IN relationships | id(r)]
AND relation.created >= datetime('2022-10-01')
AND relation.created < datetime('2023-01-01')
RETURN start_node, relation, end_node
This query work pretty well, but still there is a problem that it can return multiple subgraphs that are not connected anymore (because of the filtering I'm applying on the previous step).
Can you advise me a better / right way to filter the subgraph from the subgraphAll
output?
Thanks!