Question

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?

Was it helpful?

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).

OTHER TIPS

Node labels can be imported using the -t switch of the import-graphml command.

neo4j-sh (?)$ help import-graphml

[...]
-t   Import labels from labels node attribute and/or labels property.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top