Stuck on one thing
The procedure apoc.nodes.link works fine for me (I have a lot nodes of type, say, "Transaction", having inputs "Address"), and i wanna connect these inputs within each transaction
But the problem is that i want not only connect inputs for a current transaction, but also pass Transaction.timestamp to all these connections
And i can't figure out how
Groupping by is too slow, that's why i'm trying to use exactly this method
I wanna connect these people (Red edges) for each such transaction with several inputs for further GDS methods
CALL apoc.periodic.iterate(
"
MATCH
(tx:Transaction)
where
tx.input_count > 1
RETURN id(tx) as tx_id
",
"
MATCH (tx:Transaction) <-[p:Payment]-(a:Address)
WHERE id(tx) = tx_id
WITH tx.hash as hash, tx.timestamp as timestamp, collect(a) as inputs, collect(id(a)) as inputs_ids
CALL apoc.nodes.link(inputs, 'Cluster_links_experimental')
And the method apoc.nodes.link works good (much faster than aggregating by edges)
But its problem is that it is not possible to pass Transaction parameters such as hash and timestamp to these relationships (is it?)
It would be great if the APOC method could either not only set Label, but also pass those parameters, or just could return the ids of created relationships - but not the case
So how can i do this?
Please let me know if im clear, really appreciate your help. Any help and ideas
match(n:X)
with collect(n) as nodes
unwind range(0,size(nodes)-2) as index
with nodes[index] as startNode, nodes[index+1] as endNode
merge(startNode)-[r:REL{a:0, b:"red"}]->(endNode)
CALL apoc.periodic.iterate(
"
MATCH (tx:Transaction)
where tx.input_count > 1
RETURN tx
",
"
MATCH (tx)<-[:Payment]-(a:Address)
WITH tx.hash as hash, tx.timestamp as timestamp, collect(a) as inputs, collect(id(a)) as inputs_ids
unwind range(0,size(inputs)-2) as index
with inputs[index] as startNode, inputs[index+1] as endNode, hash, timestamp
merge(startNode)-[:Cluster_links_experimental{a:0, b:'red'}]->(endNode)
",
{batchSize: 1000, parallel: false}
) YIELD total, errorMessages
Of course, set the relationship properties appropriately.
Thank you so much - it works good and pretty fast!
And while we are here
You've removed that condition (reteurning id(tx) in first subquery and comparing node id in the second subquery), but i've read this article:
So it says it's not the best way to do it? Or not the case?