通过REST与LOAD CSV发送暗号脚本不是为我工作(Sending Cypher script

2019-09-29 16:18发布

我试图通过REST发送这个暗号脚本:

{"statements":[{"statement":"LOAD CSV WITH HEADERS FROM \"http://localhost:9000/api/csv/Countries/csv\" as csvLine
MERGE (c:Country { Code: csvLine.Code })

RETURN c","resultDataContents":["row"],"includeStats":true}]}

但我正在逐渐回:

{"results":[],"errors":[]}

如果我在的Neo4j浏览器相同的嵌入式查询它工作正常。 以下工作正常:

{"statements":[{"statement":"CREATE n RETURN n","resultDataContents":["row"],"includeStats":true}]}

我得到的结果:

{"results":[{"columns":["n"],"data":[{"row":[{}]}],"stats":{"contains_updates":true,"nodes_created":1,"nodes_deleted":0,"properties_set":0,"relationships_created":0,"relationship_deleted":0,"labels_added":0,"labels_removed":0,"indexes_added":0,"indexes_removed":0,"constraints_added":0,"constraints_removed":0}}],"errors":[]}

任何人有任何想法,我做错了什么? 为什么我会得到空的错误,如果它不工作?

Answer 1:

变化resultDataContents从值["row"]["row", "graph"]如果你想恢复回的图形结果(节点和链接)。

更新后的JSON有效载荷应该是这样的:

{"statements":[{"statement":"LOAD CSV WITH HEADERS FROM \"http://localhost:9000/api/csv/Countries/csv\" as csvLine
MERGE (c:Country { Code: csvLine.Code })

RETURN c","resultDataContents":["row", "graph"],"includeStats":true}]}

或者你可以返回回特性,并接收数据集列和行。

{"statements":[{"statement":"LOAD CSV WITH HEADERS FROM \"http://localhost:9000/api/csv/Countries/csv\" as csvLine
MERGE (c:Country { Code: csvLine.Code })

RETURN c.Code","resultDataContents":["row"],"includeStats":true}]}

没有结果的查询返回了的原因是因为你要求一个节点的属性在resultDataContents作为返回结果,但返回的节点RETURN c 。 当您指定要行/列结果返回,您必须在返回的属性,而不是节点RETURN声明。



Answer 2:

虽然我清楚了一些问题,我的匹配与格式REST期待在查询结果的返回部分,真正的问题是,在JSON包中的语句不能去多条线路上。 这解释了所有我有症状。 感谢您的帮助,肯尼! :)



文章来源: Sending Cypher script with LOAD CSV via REST isn't working for me