Sunday 15 March 2015

Creating time-based ('After', 'Before') relationships in Neo4j -



Creating time-based ('After', 'Before') relationships in Neo4j -

my goal create relationship between events ('next', 'prev'). have set of info 2 types of nodes, , 1 relationship. (:person) -[:at]-> (:event). in fact, @ multiple events (think football game games). each (:event) has .datenum property number of days since whenever, doesn't matter.

i'd to, each person, create relationship links events based on :event.datenum using relationship -[:next]->. thus, i'd see (:event)-[:next]->(:event). having problem creating relationship because can't think of way identify, each person, first (minimum .datenum) event. need sort of grouping clause found ordering of .datenums direct relationships.

i'm pretty new cypher figure must missing (or still thinking in rdbms). thoughts? thanks-

i think if want create ordering between specific person's attendance @ event need introduce concept of attendance e.g.

(:person)-[:attended]->(:attendance)-[:event]->(:event)

otherwise if have 'at' relationship there isn't way order can't create relationship between relationships.

so assuming have concept of attendance, order attendances this:

match (p:person)-[:attended]->(attendance) p, attendance order p.name, attendance.timestamp p, collect(attendance) attendances foreach(i in range(0, length(attendances)-2) | foreach(si in [attendances[i]] | foreach(si2 in [attendances[i+1]] | merge (si)-[:next]->(si2))))

hope makes sense. allow me know if not.

neo4j

No comments:

Post a Comment