[英]How to insert JSON bulk data in Neo4j?
I am having trouble inserting a large number of JSON data in Neo4j 我在Neo4j中插入大量JSON数据时遇到问题
If I insert more data in Neo4j means it will take more time to run it and makes my performance very slow and I have to wait for 10-15 mins for the complete process of insertion. 如果我在Neo4j中插入更多数据,这意味着将花费更多时间来运行它,并使我的性能非常慢,并且我必须等待10-15分钟才能完成整个插入过程。
Is there any solution or any suggestion on how to insert bulk data? 关于如何插入批量数据,是否有任何解决方案或建议? I have used merge query while inserting the JSON data and there is no unique value so I picked some combinations to make object model in merge query.
我在插入JSON数据时使用了合并查询,并且没有唯一值,因此我选择了一些组合以在合并查询中创建对象模型。
dir_port
sym_dev
ini_tiator_group_name
host_lun
sym_metrix_id
dir_port
sym_dev
ini_tiator_group_name
host_lun
sym_metrix_id
( There is no unique constraint in this query to get object model we have used combinations of values I have mentioned above ) ( 此查询中没有唯一约束来获取对象模型,我们使用了我上面提到的值的组合 )
This is my query: 这是我的查询:
CALL apoc.load.json('file:<path>')YIELD value AS row
UNWIND row.symdev AS symdevs
MERGE (accesssymdev:symaccess_symdev {
sym_dev:symdevs.sym_dev,
ini_tiator_group_name:symdevs.ini_tiator_group_name,
host_lun:symdevs.host_lun,
symid:symdevs.sym_metrix_id,
dir_port:symdevs.dir_port
})
ON CREATE SET
accesssymdev.attr_percentage = symdevs.attr_percentage,
accesssymdev.cap_mb = toFloat(symdevs.cap_mb),
accesssymdev.physicaldevicename = symdevs.physicaldevicename;
This is my sample JSON value: 这是我的示例JSON值:
{ "dir_port": "011:000", "attr_percentage": "(m)", "sym_metrix_id": "123456", "sym_dev": "05467", "ini_tiator_group_name": "cluster_abcdefgh_mnop_sss1", "host_lun": "52", "cap(mb)": "246369", " physicaldevicename": "not visible" }, { "dir_port": "001:000", "attr_percentage": "(m)", "sym_metrix_id": "123456", "sym_dev": "03as1", "ini_tiator_group_name": "cluster_abcdefgh_mnop_sss1", "host_lun": "54", "cap(mb)": "210000", " physicaldevicename": "not visible" },
If you don't have a node Key or an index or a constraint on your MERGE
, then more data you will have, more time the MERGE
will take. 如果您在
MERGE
上没有节点Key或索引或约束 ,那么您将拥有更多数据, MERGE
将花费更多时间。
In your case, the best is to create a node key : CREATE CONSTRAINT ON (n:symaccess_symdev) ASSERT (n.sym_dev, n.ini_tiator_group_name, n.host_lun, n.symid, n.dir_port) IS NODE KEY
对于您而言,最好的方法是创建一个节点密钥:
CREATE CONSTRAINT ON (n:symaccess_symdev) ASSERT (n.sym_dev, n.ini_tiator_group_name, n.host_lun, n.symid, n.dir_port) IS NODE KEY
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.