Apoc.periodic.repeat with node similarity

hlow
Node Link

Hi,
I'm trying to use apoc.periodic.repeat to recalculate the similarity score everyday, but it doesn't seem to be working. My code works when I don't throw it in apoc though.

Could this be due to an incompatibility issue with apoc and the GDS library?

example:
step1:
CALL apoc.periodic.repeat('title', "
CALL gds.graph.drop('grapheme')
YIELD graphName, modificationTime
;
",606024);

step2:
CALL apoc.periodic.repeat('title', "

CALL gds.graph.create(
'grapheme',
'User',
{
RELATIONSHIP: {orientation: 'UNDIRECTED'}}
)
;
",606024);

I can include the rest of the code if needed.
Thank you!

1 REPLY 1

giuseppe_villan
Graph Fellow

@hlow

It seems the apoc.periodic.repeat procedure with a statement containing other procedures (not all anyway), doesn't work if something is returned.

I just created an issue for this The apoc.periodic.repeat procedure doesn't work with some statements which return something · Issue ...


However, waiting for the fix, you could use this bad but working workaround,
that is, by adding create (n:ToDelete) delete n to return nothing at the end of the query.

STEP 1 (creation, if not executed):

CALL gds.graph.create(
'grapheme',
'User',
{RELATIONSHIP: {orientation: 'UNDIRECTED'}}) 

STEP 2 (apoc.periodic.repeat):

CALL apoc.periodic.repeat('myJob', "CALL gds.graph.drop('grapheme') 
yield graphName with graphName as ignore // just to concat drop with create
CALL gds.graph.create(
'grapheme',
'User',
{RELATIONSHIP: {orientation: 'UNDIRECTED'}}) yield graphName 
create (n:ToDelete) delete n // to return nothing
", 86400000)

Note that i joined drop and create into a single statement to avoid potential errors (drop before creation and vice-versa).