Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-10-2020 08:14 PM
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 ?
Solved! Go to Solution.
12-11-2020 01:58 AM
Hello @bill.dickenson
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)
}]
Regards,
Cobra
12-11-2020 01:58 AM
Hello @bill.dickenson
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)
}]
Regards,
Cobra
12-11-2020 05:50 AM
ok - so not simple.
Seems like a good feature request.
Thanks
12-11-2020 11:37 AM
I'm not sure what you want exactly, but I did this:
MATCH(c:Category)-[:IS_IN]->(b:Bucket)
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.
12-12-2020 07:21 AM
That worked also. Thank you ! In the end, we used Cobra's but yours in on our "best seller" list. Thank you
All the sessions of the conference are now available online