我需要运行带有1000个对象的查询。使用/batch端点,我可以使它正常工作,但速度太慢(30秒处理300个项目)。

因此,我正在尝试与该文档页面中所述的相同方法:http://docs.neo4j.org/chunked/2.0.1/rest-api-cypher.html#rest-api-create-mutiple-nodes-with-properties

将此JSON发布到http://localhost:7474/db/data/cypher

{
    "params": {
        "props": [
            {
                "_user_id": "177032492760",
                "_user_name": "John"
            },
            {
                "_user_id": "177032492760",
                "_user_name": "Mike"
            },
            {
                "_user_id": "100007496328",
                "_user_name": "Wilber"
            }
        ]
    },
    "query": "MERGE (user:People {id:{_user_id}}) SET user.id = {_user_id}, user.name = {_user_name} "
}


问题是我收到此错误:

{ message: 'Expected a parameter named _user_id',
  exception: 'ParameterNotFoundException',
  fullname: 'org.neo4j.cypher.ParameterNotFoundException',
  stacktrace:
  ...


也许这仅适用于CREATE查询,如docs页面所示?

最佳答案

将FOREACH和MERGE与ON CREATE SET结合使用:

 FOREACH (p in {props} |
    MERGE (user:People {id:{p._user_id}})
      ON CREATE  user.name = {p._user_name})


将此JSON发布到http://localhost:7474/db/data/cypher

{
    "params": {
        "props": [
            {
                "_user_id": "177032492760",
                "_user_name": "John"
            },
            {
                "_user_id": "177032492760",
                "_user_name": "Mike"
            },
            {
                "_user_id": "100007496328",
                "_user_name": "Wilber"
            }
        ]
    },
    "query": "FOREACH (p in {props} | MERGE (user:People {id:{p._user_id}}) ON CREATE  user.name = {p._user_name}) "
}

09-28 05:54