在此图像中,您可以看到节点中的所有属性,我想要实现的是基于CUI(id)合并节点并将这些属性添加到一个初始节点。
我试过了
START first=node(*), second=node(*)
WHERE exists (first.id) and exists (second.id)
WITH first, second
SKIP 20000 LIMIT 20000
WHERE first.id= second.id
SET first=second;
但没有变化
然后我试着打电话给APOC
match (f:Disease),(b:Disease) where f.id=b.id
CALL apoc.refactor.mergeNodes([f,b]) yield node
return "none";
这给了我一个错误
ServiceUnavailable:WebSocket连接失败。由于Web浏览器中的安全限制,此Neo4j驱动程序无法使用此故障原因。请使用您的浏览器开发控制台确定失败的根本原因。常见原因包括数据库不可用,使用错误的连接URL或临时网络问题。如果您已启用加密,请确保您的浏览器配置为信任Neo4j配置使用的证书。 WebSocket
readyState
是:3
有人可以帮助查询合并节点并添加属性,这样我就不会丢失信息吗?
首先,运行此命令以创建唯一性约束并在疾病的id
属性上添加索引。 [重要]
CREATE CONSTRAINT ON (d:Disease) ASSERT d.id IS UNIQUE
然后运行以下查询以加载数据。如果节点不存在,这将创建节点并设置属性。如果节点已存在,则会附加值。
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:///ConditionConcepts.csv' AS line FIELDTERMINATOR '\t'
MERGE (disease:Disease {id: line.CUI})
ON CREATE SET
disease.name_doctor = line.name,
disease.relevance = line.cui_relevance,
disease.trials = line.trials_count,
disease.search = line.search_frequency,
disease.select = line.select_frequency
ON MATCH SET
disease.name_doctor = disease.name_doctor+", "+line.name,
disease.relevance = disease.relevance+", "+line.cui_relevance,
disease.trials = disease.trials+", "+line.trials_count,
disease.search = disease.search+", "+line.search_frequency,
disease.select = disease.select+", "+line.select_frequency