如何在LOAD CSV中设置关系类型和标签? [英] How to set relationship type and label in LOAD CSV?

查看:1110
本文介绍了如何在LOAD CSV中设置关系类型和标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有节点的数据库,并希望添加来自CSV文件的其他关系,如下所示:

I have a database of existing nodes and would like to add in additional relationships from a CSV file which looks like this:

stype,sname,sver,rel,dtype,dname,dver
A,aname,1.1,FRIEND,A,bname,2.2
B,bbb,1.2,ENEMY,A,bname,2.2

我的LOAD CSV看起来像这样。目的是匹配两个现有节点,然后链接到CSV中的值:

My LOAD CSV looks like this. The intent is to match two existing nodes then link with the values in the CSV:

LOAD CSV WITH HEADERS FROM "file:///c:/workspace/neo/demo.csv" as line
MATCH (s:line.stype {name:line.sname,version:line.sver}),
      (d:line.dtype {name:line.dname,version:line.dver})
CREATE (s)-[:line.rel}]->(d)
RETURN COUNT(*);

我尝试设置标签或关系类型时收到此错误:

Am getting this error when I try to set either the label or the relationship type:

Invalid input '.': expected an identifier character, whitespace, NodeLabel, a property map, ')' or a relationship pattern (line 2, column 14)
"MATCH (s:line.stype {name:line.sname,version:line.sver}),"

这是否支持?

推荐答案

不支持良好的参数化标签。

Well parameterized labels are not supported.

您可以添加一个WHERE语句,指定您想要的MATCH的标签:

In your case you can add a WHERE statement specifying the label for the MATCH you want :

MATCH (s {name:line.sname,version:line.sver}), (d {name:line.dname,version:line.dver})
WHERE line.stype IN labels(s) AND line.dtype IN labels(d)

干杯,

Chris

这篇关于如何在LOAD CSV中设置关系类型和标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆