Hi, Fellow graph enthusiasts!
I'm stuck on an issue and need your help to optimise a cypher query.
I have a cypher query which pulls up a graph using the following query:
match p=(f:Material)<-[*0..8]-(s:MatPlant)<-[*0..8]-(r:MatPlant)<-[*0..1]-(v:Vendor) where f.node_id in ['abc|xyz001'] and s.matl_typ in ['SEMI FINISHED GOODS','FINISHED GOODS'] and r.matl_typ in ['RAW/PKG MATERIALS','FINISHED GOODS'] return p
This returns a list of paths and the path consists of a List of Segments.
I'm currently firing the above query from a microservice and parsing the response to get nodes and relations to create a nested json, the structure of which is similar to the actual graph which gets rendered in the neo4j browser by the above query.
The issue is that each path contains a lot of common segments, and hence a lot of duplicate nodes and relations in the whole response from neo4j, causing the response from neo4j to bloat up to even more than a GB.
What I need is to get all the distinct nodes and relations from all the paths combined.