Hello, I am importing from CSV data with Sessions and Events. Sessions point to Events, where each Event name is in sequential order (event1, event2, event3, etc). I would like each event to point to the next event in the sequence, like event1-->event2-->event3. Attached is a graph of this desired effect.
I've been able to get Sessions to point to events with HAS_EVENT just fine. But I've not been able to get the NEXT to work for events in sequential order.
I would be very thankful if anyone could help me achieve this . Thank you!
will you have more than 10 events, as that will not work alphabetically unless you zero pad the numbers, such as event01, event02....event11, etc. With one zero, you would be limited to 100 events, with two zeros 1000 events, etc.
The events are actually numbered like "1", "2", "3" without "event". I just put the "event" in there to make demonstration easier, but I did not foresee the case you just discussed. So it can be sorted with toInteger.
Try this. You can adjust to your property that equals 'rank'.
match(s:Sequence)-[:HAS_EVENT]->(e:Event)
with s, e
order by e.rank
with s, collect(e) as events
unwind range(0,size(events)-2) as index
with events[index] as e0, events[index+1] as e1
create(e0)-[:NEXT]->(e1)