简体   繁体   English

通过REST端点进行密码查询:未创建关系

[英]Cypher query via the REST endpoint : relationship not created

I'm using Neo4j 2.0.1 Community. 我正在使用Neo4j 2.0.1社区。 I try to insert a relationship in the graph by sending the query through the REST endpoint. 我尝试通过REST端点发送查询,以在图中插入关系。

My relationship query is very simple: 我的关系查询非常简单:

    MATCH (t1:Test { name : 'TEST_1' }), (t2:Test { name : 'TEST_2' }) CREATE (t1)-[:REL_TEST]->(t2)

I call it this way in Powershell: 我在Powershell中这样称呼它:

    $postParams  = "{ `"query`" : `"MATCH (t1:Test { name : {test1} }), (t2:Test { name : {test2} }) CREATE (t1)-[:REL_TEST]->(t2)`",`"params`" : { `"test1`" : `"TEST_1`", `"test2`" : `"TEST_2`" } }"

    Invoke-WebRequest -Uri http://localhost:7474/db/data/cypher -Method POST -Body $postParams -Headers @{"Accept"="application/json; charset=UTF-8";"Content-Type"="application/json"}

And I got the following response: 我得到以下回应:

    StatusCode        : 200
    StatusDescription : OK
    Content           : {
                          "columns" : [ ],
                          "data" : [ ]
                        }
    RawContent        : HTTP/1.1 200 OK
                Access-Control-Allow-Origin: *
                Content-Length: 40
                Content-Type: application/json; charset=UTF-8
                Server: Jetty(9.0.z-SNAPSHOT)

                {
                  "columns" : [ ],
                  "data" : [ ]
                }
    Forms             : {}
    Headers           : {[Access-Control-Allow-Origin, *], [Content-Length, 40], [Content-Type, application/json; charset=UTF-8], [Server, Jetty(9.0.z-SNAPSHOT)]}
    Images            : {}
    InputFields       : {}
    Links             : {}
    ParsedHtml        : mshtml.HTMLDocumentClass
    RawContentLength  : 40

But the relationship is not created. 但是没有建立关系。 If I then type the same query in the browser UI, it works. 如果然后在浏览器用户界面中键入相同的查询,它将起作用。 I don't get what I'm an doing wrong, especially since the query works in the browser and the REST calling procedure works for inserting a node for example. 我没有做错什么,特别是因为查询在浏览器中有效,而REST调用过程例如可用于插入节点。

Are you certain that your query is not working. 您确定查询无法正常工作。 You are not returning any data so it's possible it is being created without your knowing it. 您不会返回任何数据,因此有可能在您不知道的情况下创建了这些数据。

You could try something like this 你可以尝试这样的事情

MATCH (t1:Test{name: {test1}}), (t2:Test{name: {test2}})
CREATE (t1)-[rel:REL_TEST]->(t2)
RETURN rel

If you don't get the rel in your response it means the rel wasn't created probably because at least one of the MATCH es failed. 如果您没有在响应中得到rel ,则意味着未创建相关结果,可能是因为至少有一个MATCH失败。 Try returning t1 and t2 as well to see if they are working as expected. 尝试同时返回t1t2 ,以查看它们是否按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM