0
votes

I'm trying to populate my Neo4j database using graphml using the Neo4j shell and neo4j-shell-tools.

Right now, I'm just trying to import the following example graphml:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
        http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
    <key id="d0" for="node" attr.name="color" attr.type="string">
        <default>yellow</default>
    </key>
    <key id="d1" for="edge" attr.name="weight" attr.type="double"/>
    <graph id="G" edgedefault="undirected">
        <node id="n0">
            <data key="d0">green</data>
        </node>
        <node id="n1"/>
        <edge id="e0" source="n0" target="n1">
            <data key="d1">1.0</data>
        </edge>
    </graph>
</graphml>

The file appears to import just fine, and I receive the following message after import:

neo4j-sh (?)$ import-graphml -i "C:\Users\CZ82FF\Documents\graph_data\in.xml" -t -c
GraphML-Import file C:\Users\CZ82FF\Documents\graph_data\in.xml rel-type RELATED_TO batch-size 40000 use disk-cache true
finish after 3 row(s)  0. 99%: node
GraphML import created 3 entities.

However, when I run the following cypher query to return all nodes in neo4j, nothing is returned:

MATCH (n) RETURN n
1

1 Answers

0
votes

I found out that the local path I was providing to the neo4j-shell was incorrect, so the database files were being created in the wrong directory.

My original path was to the neo4j directory:

PS C:\Users\CZ82FF\Documents\neo4j> .\bin\neo4j-shell -path C:\Users\CZ82FF\Documents\neo4j\

Instead I needed to provide the path to the graph.db directory:

PS C:\Users\CZ82FF\Documents\neo4j> .\bin\neo4j-shell -path C:\Users\CZ82FF\Documents\neo4j\data\databases\graph.db

I also had to stop the neo4j service, delete all the existing files in graph.db, and run my shell commands before restarting the neo4j service.