Search code examples
neo4jcypherneo4j-apoc

Unable to load NODE 4:db8c4fa***.. error when i using CALL apoc.create.vNode


Here's a cypher that finds a pattern, creates a virtual node, and then creates a relationship with the real node.

MATCH (account:Account:Iam)-[:DATE]->(date:Date)-[:ACTED]-(start_log:Log)-[:ACTED*1..]->(end_log:Log)-[:DETECTED]->(rule:Rule)
WHERE account.name = 'ar_hk'

WITH account, date, start_log, end_log, rule

MATCH path=(start_log)-[:ACTED*]->(end_log)

WITH account, date, start_log, end_log, rule, path

WITH account, date, start_log, end_log, rule, path,
     nodes(path) AS all_nodes

WITH account, date, start_log, end_log, rule, path, all_nodes,
     all_nodes[0] AS virtual_start,
     all_nodes[-1] AS virtual_end

WITH account, date, start_log, end_log, rule, virtual_start, virtual_end, length(path) AS path_length

CALL apoc.create.vNode(['Analysis'], {path_length: path_length}) YIELD node AS virtual_analysis

CREATE (virtual_start)-[:VIRTUAL_START]->(virtual_analysis)
CREATE (virtual_analysis)-[:VIRTUAL_END]->(virtual_end)

RETURN account, date, start_log, end_log, rule, virtual_analysis

The error 'Unable to load NODE 4:db8c4fa9-255d-4df3-a0e1-0818e92d3b53:-2369' occurs.

Here is my second cypher :

MATCH (account:Account:Iam)-[:DATE]->(date:Date)-[:ACTED]-(start_log:Log)-[:ACTED*1..]->(end_log:Log)-[:DETECTED]->(rule:Rule)
WHERE account.name = 'ar_hk'

WITH account, date, start_log, end_log, rule

MATCH path=(start_log)-[:ACTED*]->(end_log)

WITH account, date, start_log, end_log, rule, path

WITH account, date, start_log, end_log, rule, path,
     nodes(path) AS all_nodes

WITH account, date, start_log, end_log, rule, path, all_nodes,
     all_nodes[0] AS virtual_start,
     all_nodes[-1] AS virtual_end

CALL apoc.create.vNode(['Analysis'], {path_length: length(path)}) YIELD node as virtual_analysis

WITH account, date, start_log, end_log, rule, virtual_start, virtual_analysis, virtual_end

CREATE (virtual_start)-[:START]->(virtual_analysis)-[:END]->(virtual_end)

RETURN account, date, start_log, end_log, rule, virtual_analysis

but, The error 'Unable to load NODE 4:db8c4fa9-255d-4df3-a0e1-0818e92d3b53:-2369' still occurs.

What did I do wrong?

Similar questions have been created before, but I don't think there are any questions about virtual nodes and virtual relationships.


Solution

  • You can't connect a real node with a virtual node using a real relationship (see 3rd paragraph in the docs).

    But you can connect it with a virtual relationship:

    CALL apoc.create.vRelationship(virtual_start, 'VIRTUAL_START', {}, virtual_analysis)
    CALL apoc.create.vRelationship(virtual_analysis, 'VIRTUAL_END', {}, virtual_end)
    

    For more, check out the docs on apoc.create.vRelationship.