使用Spring / Java的apoc.periodic.iterate进程动态列表

时间:2019-02-02 04:29:13

标签: neo4j spring-data-neo4j neo4j-ogm neo4j-apoc

  1. 我想传递需要迭代的列表,并从中创建节点和关系。

  2. 我现在使用的是Apoc.periodic.iterate,因为以前我尝试过使用unwind进行操作,由于并行执行导致死锁。

  3. 帮我修复当前代码部分。

  4. 我正在分块处理超过900k数据。我将从kafka主题中阅读。

    当前代码部分:       ToString

    上一个代码部分: @Query("CALL apoc.periodic.iterate("+"\"" + " UNWIND $items as item return item\" ," + "\"MERGE (src:Item {name: item.name}) " + " ON CREATE SET src.name = item.name, " + " src.updateDate = {processDate} " + "MERGE (dest:ItemDet {upc: item.upc}) " + " ON CREATE SET dest.upc = item.upc, " + " dest.creationDate = {processDate} " )\", {batchSize:1000, parallel:false,iterateList:true,params:{items:{items}}})") Result mergeItems(@Param("items") List<?> items, @Param("processDate") String processDate);

错误日志


@Query("UNWIND {items} as item MERGE(src:Item {name: item.name}) "
             + " ON CREATE SET src.name = item.name, "
             + " src.updateDate = {processDate} "
             + "MERGE (dest:ItemDet {upc: item.upc}) "
             + " ON CREATE SET dest.upc = item.upc, "
             + "   dest.creationDate = {processDate} ")
Result mergeItems(@Param("items") List<?> items,
                @Param("processDate") String processDate); 

1 个答案:

答案 0 :(得分:0)

1) Its due to syntax error .I have found the fix.

 @Query("CALL apoc.periodic.iterate("+"\""
    + " UNWIND $items as item return item\" ,"
    + "\"MERGE (src:Item {name: item.name}) "
    + " ON CREATE SET src.name = item.name, "
    + " src.updateDate = {processDate} "
    + "MERGE (dest:ItemDet {upc: item.upc}) "
    + " ON CREATE SET dest.upc = item.upc, "
    + "   dest.creationDate = {processDate} "\", 
    {batchSize:1000, parallel:false,iterateList:true,params:{items:{items},{processDate:{processDate}}}})")
     Result mergeItems(@Param("items") List<?> items,
       @Param("processDate") String processDate);
</CODE>