Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-17-2020 05:22 AM
Given a series of unique sequential nodes of certain types: LogIn->UpdateProfile
, LogIn->AddToCart->CheckOut
cypher example:
CREATE (e1:Event {type: 'LogIn', uuid: '...'}),
(e2:Event {type: 'UpdateProfile', uuid: '...'}),
(e3:Event {type: 'LogIn', uuid: '...'}),
(e4:Event {type: 'AddToCart', uuid: '...'}),
(e5:Event {type: 'CheckOut', uuid: '...'}),
(e1)-[:NEXT]->(e2)// e1 relates to e2
(e3)-[:NEXT]->(e4)
(e4)-[:NEXT]->(e5)// e3 relates to e4, and e4 to e5
How can I get a list of paths grouped by similar patterns and the number of times they appear.
Ex:
LogIn - UpdateProfile = 5 times
LogIn - AddToCart - CheckOut = 2 times
The :NEXT
relation represents the sequence and the type
property is the type of event.
07-24-2020 07:38 AM
I think you should be able to do it with a query like this:
MATCH path = (e:Event)-[:NEXT*]->(other:Event)
RETURN [event in nodes(path) | event.type], count(*) AS count
ORDER BY count DESC
And if you only want to capture longest paths, you could make sure that the last event in the chain (other
) doesn't have a NEXT
relationship:
MATCH path = (e:Event)-[:NEXT*]->(other:Event)
WHERE not((other)-[:NEXT]->())
RETURN [event in nodes(path) | event.type], count(*) AS count
ORDER BY count DESC
All the sessions of the conference are now available online