Search code examples
neo4jgraphml

Import GraphML to Neo4j: how to specify node labels?


I want to import my GraphML data to Neo4j database (version 2.0.1). The question is, how can I specify Neo4j node label in GraphML?

I tried the following to no avail:

<!--This format is used when exporting Neo4j data to GraphML-->
<node id="1" labels=":PAGE">
    <data key="labels">:PAGE</data>
</node>

So, how should I format my XML so Neo4j could recognize node labels?


Solution

  • Unfortunately, I was not able to find any documentation about the import behavior. So I invented a workaround.

    I imported GraphML data set to Neo4j using the following node structure:

    <node id="1">
        <!--This code doesn't really force Neo4j to create PAGE label-->
        <data key="label">PAGE</data>
    </node>
    

    Then I executed the following Cypher command:

    MATCH (n)
    WHERE n.label='PAGE'
    SET n :PAGE
    

    After that, Neo4j applied PAGE label to each node that matches the search condition.

    At the moment, this workaround is acceptable for me. It would be better to find the real solution, though (if any).