我有一个问题,我如何合并文档(Doc1,Doc2和Doc3)的节点,以获得漂亮的3个开始模式。
for index, row in import_ds.iterrows():
ind = ind+1
graph.cypher.execute("MERGE (Document:Document"+str(fnum)+" {Document:\"Doc"+str(fnum)+"\"})")
graph.cypher.execute("MERGE (Type:Type {Type:\""+str(row['type'])+"\"})<-[:HAS_TYPE]-(Word:Word {Word:\""+str(row['token_low'])+"\"})-[:IS_IN]->(Document:Document"+str(fnum)+" {Document:\"Doc"+str(fnum)+"\"})")
(WordType)<-[:HAS_TYPE]-(Word)-[:IS_IN]->(Document) http://www.yottalabs.co.uk/ss.png
[code output - Neo4j browser][1]
答案 0 :(得分:0)
通常先将节点合并到rels:
MERGE (type:Type {Type: {type}})
MERGE (word:Word {Word:{token_low}})
MERGE (document:Document {Document:{doc}})
MERGE (type)<-[:HAS_TYPE]-(word)
MERGE (word)-[:IS_IN]->(document)
MERGE (document:Document {Document:{doc}})
SET document.foo = {new_data}.foo, document.bar = {param_bar}