neo4j-contrib/neo4j-apoc-procedures

GraphML import doesn't work as expected when the metadata key ID id different from attribute name

sairamch04 opened this issue · 2 comments

Guidelines

Please note that GitHub issues are only meant for bug reports/feature requests. If you have questions on how to use APOC, please ask on the Neo4j Discussion Forum instead of creating an issue here.

Expected Behavior (Mandatory)

Let's take the sample GraphML file (took from https://neo4j.com/labs/apoc/4.1/overview/apoc.import/apoc.import.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="name" for="node" attr.name="name"/>
<key id="title" for="node" attr.name="title"/>
...
<graph id="G" edgedefault="directed">
<node id="n188" labels=":Movie"><data key="labels">:Movie</data><data key="title">The Matrix</data><data key="tagline">Welcome to the Real World</data><data key="released">1999</data></node>
<node id="n189" labels=":Person"><data key="labels">:Person</data><data key="born">1964</data><data key="name">Keanu Reeves</data></node>
<node id="n190" labels=":Person"><data key="labels">:Person</data><data key="born">1967</data><data key="name">Carrie-Anne Moss</data></node>
...
</graph>
</graphml>

In the example, the Key ID is the same as attr.name
i.e

<key id="name" for="node" attr.name="name"/>

However, if the key id is different from attr.name, the neo4j doesn't take the property name as attr.name, but rather takes id. This defeats the purpose for which we have attr.name which is to have human-readable names.

I'm using jgrapht to export the graph to graphML to finally use in neo4j and jgrapht makes excessive use of attr.name.

Actual Behavior (Mandatory)

if the key id is different from attr.name, the neo4j takes the property name as id instead of attr.name. This defeats the purpose for which we have attr.name which is to have human-readable names.

How to Reproduce the Problem

Simple Dataset (where it's possibile)

//Insert here a set of Cypher statements that helps us to reproduce the problem

Steps (Mandatory)

Screenshots (where it's possibile)

Specifications (Mandatory)

Currently used versions

Versions

  • OS: MAC latest as of today
  • Neo4j: (latest)
  • Neo4j-Apoc: (latest)

I created a temporary script to unblock myself, by replacing id with attr.namehttps://gist.github.com/sairamch04/715fe6dd277347ee9c94c5ac2ced11fc

Hey! I was unable to reproduce this (or I have misunderstood the problem).

With this graphml file:

<?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="prop1" for="node" attr.name="born"/>
<key id="prop2" for="node" attr.name="name"/>
<graph id="G" edgedefault="directed">
<node id="n189" labels=":Person"><data key="labels">:Person</data><data key="prop1">1964</data><data key="prop2">Keanu Reeves</data></node>
</graph>
</graphml>

I have the keys at the top which map the id prop1 and prop2 to their real names of born and name. When I import I end up with a node:

MATCH (n) RETURN n;
{
  "identity": 0,
  "labels": [
    "Person"
  ],
  "properties": {
    "born": "1964",
    "name": "Keanu Reeves"
  },
  "elementId": "4:0d140b2a-fae9-435f-bb8a-d272751f3dbf:0"
}

As you can see, the properties aer called born and name as I had mapped them.