cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Adding python function into apoc.periodic.iterate

oleg_neo4j
Graph Buddy

Hi,
I'm trying to add a calculated property to each of a bunch of nodes based on the 'SentText' property of that node (a BERT sentence embedding vector calculated in Python in this case).
I've found an example of apoc.periodic.iterate below (https://towardsdatascience.com/batching-transactions-in-neo4j-1001d12c9a4a) that I've modified to show something like what I'm looking for.
Is there a way to do this? How else can I do this?

CALL apoc.periodic.iterate(  // first statement
"MATCH (s:Sentence)
WHERE EXISTS(s.SentText)
RETURN s, s.SentText",
// second statement
"MERGE (s)
SET s.BertVector = PythonBertFunction(s.SentText)",
// configuration
{batchSize:50000})

 Thank you!

1 REPLY 1

Interesting!

Is there a way for you to write the Bert function in Java? In that case you can build your own procedure and load into the db.

Otherwise, you may need to use the Python driver and handle the batches on your application layer. 

Oh, y’all wanted a twist, ey?