A simple list of relationships

I am exporting the database out to a flat file.I am extracting the nodes without any problems but I am finding it hard to extract the relationships. For example, the database load has a definitions

merge (a:ProgNode {inode:0, name:'Line-1'});
merge (a:ProgNode {inode:1, name:'Line-2''});
match (a:ProgNode {inode:0}), (b:ProgNode {inode:1}) merge (a)-[x:RUNS]-(b);

there are only 29 nodes in the database. (inode:0 to inode:28) and I can get the nodes easy enough (Match (a) return a.inode, a.name) but when I try to get the relationships, I get the internal index, not inode.
So the command: match (a)-[c]-(b) return c returns

"identity": 53,
"start": 52,
"end": 0,
"type": "RUNS",

obviously this is the system generated identity, not inode. So I can't seem to extract the right set.

What I wanted was

"identity": 53,
"start": 0,
"end": 1,
"type": "RUNS",

So it would match the definition.

How do I get the inode of the internally defined ID ?

Hello @bill.dickenson :slight_smile:

This query should do the trick (you will need GDS plugin):

MATCH p=(a)-[r]-(b)
RETURN [path IN relationships(p) | {
    start: gds.util.asNode(id(startNode(path))).inode,
    end: gds.util.asNode(id(endNode(path))).inode,
    type: type(path),
    identity: id(path)


ok - so not simple.

Seems like a good feature request.


1 Like

I'm not sure what you want exactly, but I did this:

RETURN b.Name AS Buckets,
apoc.coll.sort(collect(DISTINCT c.Name)) AS Categories ORDER BY b.Name

Where there is a many to many relationship between Buckets and Categories. (Categories can belong in multiple Buckets and Buckets can contain multiple Categories).

You can then export as JSON, and for each Bucket, there will be a list of Categories.

I hope that helps.

That worked also. Thank you ! In the end, we used Cobra's but yours in on our "best seller" list. Thank you