cancel
Showing results for 
Search instead for 
Did you mean: 

Need help starting with Fraud detection and modeling time data as chains

BuilderGuy1
Node Clone

I've been digging in to Neo4j over the last 2 weeks. My goal is to analyze log data for fraudulent activities. In some of the Neo4j youtube videos, it was suggested that having the Time based log data related in a Chain was the best approach. I have some test data imported (CSV) but I'm not sure how to get the data imported in a chain of relations.

Any assistance would be greatly appreciated

Jason

1 ACCEPTED SOLUTION

Thomas_Silkjaer
Graph Buddy

You can use the APOC library to make a linked sequence, if that is what you mean:

MATCH (nodeToLink:Label)
WITH nodesToLink
ORDER BY nodesToLink.dateTimeProperty ASC
WITH collect(nodesToLink) as nodesToLinkCollection
CALL apoc.nodes.link(nodesToLinkCollection, 'NAME_OF_LINK_RELATIONSHIP')

View solution in original post

6 REPLIES 6

Thomas_Silkjaer
Graph Buddy

You can use the APOC library to make a linked sequence, if that is what you mean:

MATCH (nodeToLink:Label)
WITH nodesToLink
ORDER BY nodesToLink.dateTimeProperty ASC
WITH collect(nodesToLink) as nodesToLinkCollection
CALL apoc.nodes.link(nodesToLinkCollection, 'NAME_OF_LINK_RELATIONSHIP')

This worked!!
...but there's a quirk. My nodes are connected with the relationships pointing in the wrong direction.
I tried using DESC instead of ASC but that did not change anything.

This is my specific query:

MATCH (dt:Time)
WITH dt
ORDER BY dt.dateTimeProperty ASC
WITH collect(dt) as dtCollection
CALL apoc.nodes.link(dtCollection, 'NEXT')
RETURN dtCollection

J

Thomas_Silkjaer
Graph Buddy

Changing order should work! Is the property a datetime/temporal type?

Yes it is. ( I did a conversion from a really ugly string when importing)
J

Deleted all "NEXT" relations and tried again.
Using DESC in this attempt.

The Time nodes are ordered in Descending order and the relationship arrows are going in the correct direction.

This is not what I need.
I will need the Time nodes in ASC order and the arros pointing in an ASCending direction.
I will delete the NEXT relations and try again (maybe I did something weird the first time?)
J

SOLVED IT !
I made an error in the ORDER line.
I did not have my specific "dateTimePropery" name entered.
Replacing "dateTimePropery" with the actial name "DateTime" worked like a charm.

Thank you for all your help
J