Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sairamch04 opened this issue Jul 24, 2024 · 2 comments
Labels
core-functionality Adding new procedure, function or signature to APOC core

Comments

@sairamch04
Copy link

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)
@sairamch04
Copy link
Author

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

@gem-neo4j
Copy link
Contributor

gem-neo4j commented Aug 12, 2024

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.

@vga91 vga91 added the core-functionality Adding new procedure, function or signature to APOC core label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-functionality Adding new procedure, function or signature to APOC core
Projects
Status: Core issues
Development

No branches or pull requests

3 participants