Search code examples
jsonimportneo4jcypherneo4j-apoc

Neo4j apoc load json: No data in Neo4j


I am using exporting neo4j all db to json using apoc APIs & again importing with same. Import query executes successfully but cannot find any data in neo4j.

Export query:

CALL apoc.export.json.all('complete-db.json',{useTypes:true, storeNodeIds:false})

Import query:

CALL apoc.load.json('complete-db.json')

When I execute:

MATCH (n) RETURN n

It shows no results found.


Solution

  • This is a little bit confusing but apoc.load.json just reads(loads) data from the JSON File/URL.

    It doesn't import the data or create the graph. You need to create the graph(nodes and/or relationships) using the Cypher statements.

    In this case, you just read the file and didn't do anything with it so statement executed successfully. Your query isn't an import query, it's a JSON load query.

    Refer the following example for import using apoc.load.json:

    CALL apoc.load.json('complete-db.json') YIELD value
    UNWIND value.items AS item
    CREATE (i:Item(name:item.name, id:item.id)