Hi All,
I am trying to create a relationship between the below path where all nodes have a date property to other nodes present in my Graph DB with rest of the dates like '2021-05-01' , '2021-06-01' ,,'2021-07-01'etc. but the relationship should be created where every month date is connected to the next month date
I have written this query : Match (a:Storage),(b:Storage)
where b.date=a.date+duration('P1M')
create (a)-[r:impact]->(b)
This works fine and creates the relation between all nodes but I just want to create relation between the nodes shown in the picture to just their next month i.e in the picture date is '2021-04-01' (but it can be any date) so it should be connected to nodes with date '2021-05-01' only and not connected further to '2021-06-01'. I want to limit my relationship creation. Is it possible ? And how to achieve it .
I just tried this what you suggested so this is also creating the relationship between all nodes all dates basis 1 month gap like '2021-04-01' connected to '2021-05-01' and then to '2021-06-01' and so on till '2023-03-01' (max date in my DB). I am getting this
So I cannot create it by limiting a:Storage basis TRANSPORTED because the other month Storage nodes like '2021-06-01', '2021-07-01' etc also have TRANSPORTED relationship. Sorry, I didn't mention this before that those months are also separate paths with TRANSPORTED Relation that I have in my DB.
One trouble is that in order to have only one relatioship "IMPACT" you should be able to query what you are creating, which is not possible within one query.
A simple solution, even if not the prettiest, would be to run a second query to delete the useless relationship in a chain:
MATCH (a:Storage)-[:IMPACT]->(b:Storage)-[rel:IMPACT*]->(c:Storage)
DELETE rel