I want to perform a batch operation on a group of nodes that have already been saved in neo4j, eventually the relationship between Make them I have something like that with gdb.transaction (): For s_id, nodlist in d_id: sn = nidx ['nid'] [s_id] .single dn = nidx ['nid'] [D_id] .single
where Thanks You can do this with a batch loader, but this one It would be easy to do with Gremlin script. If your And here's how you will execute it in the bulb - You will need to modify it for neo4jrestclient ... nidx is an index that I created (and 'nud', s_id key / value added). However, it seems that
nidx ['nid'] [s_id] is a TransactionOperationProxy object, although I was intending to be a node for it, is there any way that I convert it to node? Can I use it to create a relationship between at least
sn and
dn (like sn.Follows (dn))?
nodlist is a list of node-id pairs, here's the Gremlin script to batch the edges (untested) ... < Pre =
// gremlin.groovy def batch_load (nodelist, label) {g.setMaxBufferSize (0) g.startTransaction () (enter in nodelist for) {s_id = entry [0] d_id = entry [1] // If s_id and d_id are the actual node id, you do not need to get an index ... sn = g.idx ('someindex'). Get ('nid', s_id) [0] dn = g.idx ('someindex') .get ('nid', d_id) [0] g.addEdge (sn, dn, label)} g.stopTransaction (TransactionalGraph. Conclusion.SUCCESS) back true} grip (e) {g.stopTransaction (TransactionalGraph.Conclusion failure)}}
& gt; & Gt; & Gt; Graph from bulbs.neoj4server import & gt; & Gt; & Gt; G = graph ()> & gt; & Gt; & Gt; G.scripts.update ('/ path / to / gremlin.groovy') & gt; & Gt; & Gt; Script = g.scripts.get ('batch_load') & gt; & Gt; & Gt; Params = dict (nodelist = your_node_list, label = "lower") & gt; & Gt; & Gt; G.gremlin.execute (script, parameter)
Comments
Post a Comment