I have a graph containing neighbours, that is, structured in a star type schema in the language of DW modelling("Account" nodes having multiple "Fraud" nodes attached to them). I want to create a further relationship among Fruds nodes associated with an account in ascending date wise i.e for an (Account)-[:CONDUCTS]-> (Fraud)-[:NEXT]->(Next_Fraud), Now from the existing graph, I am trying to run the following query. My idea of structuring the query is; 1)select all accounts 2) pick up one account at a time 3) picks up its associated frauds 4) sort frauds according to commit date 5) create a relationship among frauds [:NEXT]
match (a:Account) with collect(a) as accts unwind(accts) as accounts match (accounts)-[c:CONDUCTING]->(f:Fraud) with f order by f.date with collect(f) as ff foreach (i in range(0,size(ff)-2)| foreach (fraud in [ff[i]] | foreach(next_fraud in [ff[i+1]] | merge (fraud)-[:NEXT]->(fraud_next) ) ) )
The above query does not produce anything. On running EXPLAIN or PROFILE, I see that in second match (match (accounts)-[c:CONDUCTING]->(f:Fraud), query is selecting all records, not the frauds of a one node at a time). Need help how would I achieve my object?