1

我正在尝试通过 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":[]}

有人知道我做错了什么吗?如果它不起作用,为什么我会得到空错误?

4

2 回答 2

0

如果要检索图形结果(节点和链接),请将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语句中返回属性而不是节点。

于 2014-09-18T06:18:57.467 回答
0

虽然我显然在将查询的 RETURN 部分与 REST 期望结果的格式匹配时遇到了一些问题,但真正的问题是 JSON 包中的语句不能多行。这解释了我的所有症状。谢谢你的帮助,肯尼!:)

于 2014-09-19T16:43:15.020 回答