joern icon indicating copy to clipboard operation
joern copied to clipboard

[Bug] Problem with the generated cypher files for edges and non existing node indexes

Open magaton opened this issue 1 year ago • 3 comments

Describe the bug The cypher files for edges do not MATCH specific node labels. Also Node ids are not indexed beforehand, which results in super slow import of edges.

Here is what neo4j-export produces:

LOAD CSV FROM 'file:/edges_CFG_data.csv' AS line
MATCH (a), (b)
WHERE a.id = toInteger(line[0]) AND b.id = toInteger(line[1])
CREATE (a)-[r:CFG {}]->(b);   

a i b are not looked up by type. This is what I can see in every generated cypher. Am I missing something, is there a reason for such implementation?

In addition, even if the nodes are looked up by Label and id, ids are not indexed beforehand. It could be written in docs that this is an offline and mandatory process, but it would be great if cypher script can be generated with CREATE INDEX statements for each Node (during the export process), since it is not easy to collect all the labels.

Expected behavior MATCH should be by Label. Index.cypher should be generated.

Desktop (please complete the following information):

  • OS latest
  • Joern Version latest
  • Java version lates

Additional context I am using latest neo4j community edition

magaton avatar Mar 08 '24 14:03 magaton

Hello, anyone? I have realised that ids are unique for all the nodes, but if you want edge cyphers to be generated without matching nodes on labels, then at least one (generic) label should be assigned during node creation and the PRIMARY index should be set for that label.

magaton avatar Mar 11 '24 15:03 magaton

Anyone?

magaton avatar Mar 13 '24 10:03 magaton

Sorry about the silence, the neo4j export is only very bare bone as you unfortunately experienced. Can you lay out for a neo4j newbie how exactly the import script is supposed to look like, with a full example? I'm happy to adapt the generated script but don't have the time to dig deep into neo4j, so maybe we can improve things together.

mpollmeier avatar Apr 09 '24 07:04 mpollmeier