Это проблема, которую я обнаружил в вашем запросе:
Иногда он пытается использовать параметры, когда они не существуют (и не нужны).
Иногда параметры некорректно заключаются в кавычки. В этих случаях также не удается использовать префикс «$» перед именем параметра.
Некоторые предложения WITH
не передают все переменные, необходимые для последующих предложений.
Это может работать лучше:
LOAD CSV WITH HEADERS FROM "file:///input.csv" AS CT
//Create vm
MERGE (vm_src:VM {name : CT.hostname_source})
MERGE (vm_dest:VM {name : CT.hostname_dest})
WITH CT, vm_src, vm_dest
// create app with label Unknown_appli
CALL apoc.do.when(CT.source_appli_name = "unknown_appli",
'MERGE (app_src:App:Unknown_appli{name: $CT.hostname_source}) RETURN app_src',
'MERGE (app_src:App{name: $CT.source_appli_name}) RETURN app_src',
{CT:CT}) YIELD value
WITH CT, vm_src, vm_dest, value.app_src as app_src
CALL apoc.do.when(CT.appli_name_dest = "unknown_appli",
'MERGE (app_dest:App:Unknown_appli{name: $CT.hostname_dest}) RETURN app_dest',
'MERGE (app_dest:App{name: $CT.appli_name_dest}) RETURN app_dest',
{CT:CT}) YIELD value
WITH CT, vm_src, vm_dest, app_src, value.app_dest as app_dest
//create calls relations
CALL apoc.do.when(CT.direction = "IN" AND vm_src.name <> vm_dest.name,
'MERGE ($vm_dest)-[:CALLS]->($vm_src)', '',
{CT:CT, vm_src:vm_src, vm_dest:vm_dest}) YIELD value
WITH CT, vm_src, vm_dest, app_src, value.app_dest as app_dest
CALL apoc.do.when(CT.direction = "IN" AND app_src.name <> app_dest.name,
'MERGE ($app_dest)-[:CALLS]->($app_src)', '',
{CT:CT,app_src:app_src, app_dest:app_dest}) YIELD value
WITH CT, vm_src, vm_dest, app_src, value.app_dest as app_dest
CALL apoc.do.when(CT.direction = "OUT" AND vm_src.name <> vm_dest.name,
'MERGE ($vm_src)-[:CALLS]->($vm_dest)', '',
{CT:CT,vm_src:vm_src,vm_dest:vm_dest}) YIELD value AS ignored1
CALL apoc.do.when(CT.direction = "OUT" AND app_src.name <> app_dest.name,
'MERGE ($app_src)-[:CALLS]->($app_dest) RETURN app_src', '',
{CT:CT,app_src:app_src,app_dest:app_dest}) YIELD value
//create child relations
MERGE (app_src)-[:CONTAINS]->(vm_src)
MERGE (app_dest)-[:CONTAINS]->(vm_dest)