Neo4j - 如何在同一批处理操作中创建唯一节点并设置标签

时间:2016-05-12 17:26:04

标签: json rest neo4j

我可以创建一个唯一的节点并在同一个批处理操作中设置标签吗?

我尝试用这个json做但不幸的是服务器失败了

[
    {
        "id": 0,
        "method": "POST",
        "to": "/index/node/PhoneBook?uniqueness=get_or_create",
        "body": {
            "key": "mobilePhone",
            "value": "9999999999",
            "properties": {
                "firstName": "fn1",
                "lastName": "ln1",
                "mobilePhone": "9999999999"
            }
        }
    },
    {
        "method": "POST",
        "to": "{0}/labels",
        "body": [
            "Contact"
        ]
    }
]

1 个答案:

答案 0 :(得分:1)

改为使用cypher:

MERGE (p:PhoneBook {mobilePhone:{phoneNo}} 
ON CREATE SET p += {properties}, SET p:Contact

params:

       {phoneNo: "9999999999", "properties": {
            "firstName": "fn1",
            "lastName": "ln1",
            "mobilePhone": "9999999999"
        }