I am querying data from MSsql server and saving it into CSVs. With those CSVs, I am modelling data into Neo4j. But Mssql database updates regularly. So,also wants to update Neo4j data on the regular basis. Neo4j has two types of nodes: 1.X and 2.Y . Below query and indexing, used to model the data:
CREATE INDEX ON :X(X_Number, X_Description,X_Type)
CREATE INDEX ON :Y(Y_Number, Y_Name)
using periodic commit
LOAD CSV WITH HEADERS FROM "file:///CR_n_Feature_new.csv" AS line
Merge(x:X{
X_Number : line.X_num,
X_Description: line.X_txt,
X_Type : line.X_Type,
})
Merge(y:Y{
Y_Number : line.Y_number,
Y_Name: line.Y_name,
})
Merge (y)-[:delivered_by]->(x)
Now there are two kinds of updates:
- There may be new X and Y nodes which can be taken care by "Merge" command.
- But there can be modifications in the properties of already created nodes X and Y....for e.g. if node X{X_Number : 1, X_Description : "abc", X_Type : "z"} but now in updated data X node properties got changed to X{X_Number : 1, X_Description : "def", X_Type : "y"}
So I don't want to create a new node for the X_Number:1 node but just want to update the existing node properties like X_Description and X_Type.