Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

import - creating dynamic nodes and building relationships dynamically by Importing data from json files

I have 3 JSON files namely VMDetails.json, Network.json, DataStore.json where the data for the graph DB is present. I had to import data from JSON files and create nodes and relationships

CALL apoc.load.json("file:///DataStore.json") YIELD value AS data
MERGE (d:DataStore{DataStore: data.DataStore})
SET d.Name = data.Name,
d.Type = data.Type,
d.Capacity = data.Capacity,
d.Free = data.Free
WITH data as data
CALL apoc.load.json("file:///Network.json")YIELD value AS net
MERGE(n:Network{Network:net.Network})
SET n.Name =net.Name
WITH net AS nw
CALL apoc.load.json("file:///VmDetails.json") YIELD value AS vm
MERGE(n:Network{Name:vm.Network})
MERGE(d:DataStore{Datastore:vm.DataStore})
MERGE(v:UserV{vmName:vm.vmName})
SET v.CPU= vm.CPU,
v.ConnectionState = vm.ConnectionState,
v.DataStore = vm.DataStore,
v.Hostname = vm.Hostname,
v.InstanceUuid = vm.InstanceUuid,
v.IpAddress = vm.IpAddress,
v.Network = vm.Network,
v.NumEthernetCards = vm.NumEthernetCards,
v.NumVirtualDisks = vm.NumVirtualDisks,
v.OverallStatus = vm.OverallStatus,
v.PowerState = vm.PowerState,
v.RAM = vm.RAM,
v.Uuid = vm.Uuid
MERGE (n)-[:connected]->(v)
MERGE (v)-[:related]->(d)

I used this query I am able to create nodes correctly While creating a relationship network node is creating the relationship with VM Node correctly but while creating the relationship with DataStore node and VM Node some new unwanted nodes are getting created and relationships are getting created with those unwanted nodes. Please tell me where I am going wrong in writing the query

question from:https://stackoverflow.com/questions/66062721/creating-dynamic-nodes-and-building-relationships-dynamically-by-importing-data

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...