变量标题未定义

时间:2016-08-31 19:12:35

标签: neo4j cypher

我在对数据库执行密码查询时收到错误Variable title not defined。对我来说,疯狂的是我提供的变量。或者至少我以为我是。对密码的HTTP POST如下所示:

POST http://.../db/data/cypher HTTP/1.1
Connection: Keep-Alive
Content-Type: text/plain; charset=utf-8
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: Basic ...
User-Agent: ...
X-Stream: true
Content-Length: 955
Host: ...

{
  "query": "MATCH (n:Event {id: {id}}) SET title = {title}, location = {location}, shortDescription = {shortDescription}, longDescription = {longDescription}, eventDates = {eventDates}, puchaseUrl = {purchaseUrl}, infoUrl = {infoUrl}, images = {images} RETURN n",
  "params": {
    "title": "Our First Event",    <<==== title supplied here
    "location": "The location",
    "shortDescription": "The short description.",
    "longDescription": "The long description is longer.",
    "eventDates": [
      {
        "date": "2016-09-01T12:00:00",
        "duration": 120,
        "Id": 0
      },
      {
        "date": "2016-09-02T14:00:00",
        "duration": 120,
        "Id": 0
      }
    ],
    "purchaseUrl": null,
    "infoUrl": null,
    "images": [
      {
        "url": "http://sandwichevents.org.uk/wp-content/uploads/2016/02/many-people-music-event-concert-awesome.jpg",
        "name": "event9_image1.jpg",
        "altText": "Something here.",
        "isDefault": false,
        "Id": 0
      },
      {
        "url": "http://www.event360.com/wp-content/uploads/2015/05/1.full-size-promo-62sm.jpg",
        "name": "event9_image2.jpg",
        "altText": "Something else here.",
        "isDefault": true,
        "Id": 0
      }
    ],
    "Id": 9
  }
}

有人可以指导我在这里做错了吗?

更新:如果您将"eventDates""images"设置为null,它甚至会失败;从而将任何复杂的数据结构留作儿童。

1 个答案:

答案 0 :(得分:1)

问题是,您尝试设置的属性都没有被视为属性,它们被视为变量,并且这些变量都不存在; title只出现,因为它是Cypher遇到的第一个,但如果错误没有停止评估,那么每个人都会抛出同样的错误。

设置属性时,前缀为包含节点的变量(SET n.title = {title},依此类推)。