Neo4j community server 4.4.5 on Ubuntu 20.04 - browser
I have the following query. The idea is to create all relationships between nodes and to signal all the missing relationship making them pointing to a fake node.
The query returns the following error
WITH is required between MERGE and MATCH (line 43, column 2 (offset: 716))
" MATCH (organisation:Organisation { id: row.organisation_id})"
^
but the WITH
statement is already there (I evidenced it between backticks).
Any idea on how to solve the problem, or in alternative, any idea how to evidence the missing matching?
MATCH (n:AssetContract)-[r]-() detach delete n,r;
MATCH (n:AssetContract) delete n;
LOAD CSV WITH HEADERS
FROM 'file:///asset_contracts.csv'
AS row
FIELDTERMINATOR ';'
WITH row
CREATE (asset_contract:AssetContract)
SET asset_contract=row,
asset_contract.uuid=apoc.create.uuid()
WITH asset_contract,row
MATCH (asset:Asset { id: row.asset_id})
WITH asset,asset_contract,row
CALL {
WITH asset,asset_contract,row
WITH asset,asset_contract,row
WHERE asset IS NULL
MERGE (noAsset:NoAsset)
MERGE (asset_contract)-[:MISSING_ASSET]->(noAsset)
return 1 as ret
}
CALL {
WITH asset,asset_contract,row
WITH asset,asset_contract,row
WHERE asset IS NOT NULL
MERGE (asset)-[:HAS_CONTRACT]->(asset_contract)
//SET asset_contract.asset_id = NULL
`WITH asset,asset_contract,row`
MATCH (organisation:Organisation { id: row.organisation_id})
WITH asset, row, organisation
CALL {
WITH asset, row, organisation
WITH asset, row, organisation
WHERE organisation IS NULL
MERGE (noOrganisation:NoOrganisation)
MERGE (asset)-[:MISSING_ORGANIZATION]->(noOrganisation)
return 2 as ret2
}
WITH asset, row, organisation
CALL {
WITH asset, row, organisation
WITH asset, row, organisation
WHERE organisation IS NOT NULL
MERGE (asset)-[:BELONGS_TO]->(organisation)
return 3 as ret3
}
}
RETURN COUNT(asset_contract)