Ibm cloud 在Bluemix Graph DB中使用set属性创建顶点的正确方法是什么?

Ibm cloud 在Bluemix Graph DB中使用set属性创建顶点的正确方法是什么?,ibm-cloud,graph-databases,ibm-graph,Ibm Cloud,Graph Databases,Ibm Graph,我正在尝试在Bluemix Graph DB服务中创建一个新的顶点。我的数据库的模式如下所示 {“propertyKeys”:[{“name”:“name”,“dataType”:“String”,“cardinality”:“SINGLE”},{“name”:“languages”,“dataType”:“String”,“cardinality”:“SET”},{“name”:“picture”,“dataType”:“String”,“cardinality”:“SINGLE”},{“na

我正在尝试在Bluemix Graph DB服务中创建一个新的顶点。我的数据库的模式如下所示

{“propertyKeys”:[{“name”:“name”,“dataType”:“String”,“cardinality”:“SINGLE”},{“name”:“languages”,“dataType”:“String”,“cardinality”:“SET”},{“name”:“picture”,“dataType”:“String”,“cardinality”:“SINGLE”},{“name”:“String”,“cardinality”:“SINGLE”;“SINGLE”},{“name”:“bytes”,“dataType”:“Integer”,“cardinality”:“SINGLE:“github_id”,“dataType:“String”,“cardinality:“SINGLE”},{“name”:“twitter_id”,“dataType:“SINGLE”},{“name”:“language_percentage”,“dataType:“Float”,“cardinality:“SINGLE”}],“vertexLabels:[{“name:“person”}],“edgeLabels:[{“name:“codes_in”,“multiality:“MULTI”},{“name:{“name”},{“name”:“multiplicity:“multiplicity:”,“VertexIndex”:[{“名称”:“vByName”,“propertyKeys”:[“名称”],“复合”:true,“唯一”:false},{“名称”:“vByPreferredLang”,“propertyKeys”:[“首选语言”],“复合”:true,“唯一”:false},{“名称”:“vByLanguages”,“propertyKeys”:[“语言”],“复合”:false,“唯一”:false}],“EdgeIndex”:[{“名称”:“eByName”,“propertyKeys”:“名称”,“复合”:true,“unique”:false},{“name”:“eByLanguagePercentage”,“propertyKeys”:[“language_percentage”],“composite”:true,“unique”:false}]
我正在尝试使用以下柱体创建顶点

{“name”:“Bob”,“languages”:[“Node”,“Python”],“picture”:https://en.gravatar.com/userimage/12148147/46ccae88e5aae747d53e0b1863f72a4e.jpg?size=200“,”首选语言“:”节点“,”github\u id“:”Bob“,”twitter\u id“:”Bob”}

但是,这会导致以下错误

{“code”:“BadRequestError”,“message”:“具有元属性的属性‘语言’需要有一个‘val’”}


languages属性的基数为SET,为SET数据类型创建属性的正确方法是什么?我会假设它是一个JSON数组。

Ryan,SET不是数据类型。您还可以将语言设置为带有分隔值的字符串


Beta版中支持的唯一类型是:String、Integer、Boolean、Float、Ryan、SET不是数据类型。您还可以将语言设置为带有分隔值的字符串


Beta版本中支持的唯一类型是:字符串、整数、布尔值、浮点值

问题在于,您试图创建一个数据类型为
List
的单顶点属性,这在IBM Graph中不受支持(仅支持JSON基元类型)。要利用具有
数据类型的属性,需要创建多个顶点属性

事实证明,TinkerPop中基数和数据类型之间的区别可能有点混淆。这里有一个例子可以说明问题:

$ curl https://ibmgraph/11/g/schema -XPOST -Hcontent-type:application/json -d '{"propertyKeys":[{"name":"languages","dataType":"String","cardinality":"SET"}]}' | jq .
{
  "requestId": "9e0ea947-f9a1-407b-ab1a-cd9b7fd5d561",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "propertyKeys": [
          {
            "name": "languages",
            "dataType": "String",
            "cardinality": "SET"
          }
        ],
        "vertexLabels": [],
        "edgeLabels": [],
        "vertexIndexes": [],
        "edgeIndexes": []
      }
    ],
    "meta": {}
  }
}
$ curl https://ibmgraph/11/g/vertices -XPOST | jq .
{
  "requestId": "2ce85907-2aca-4630-876f-31775e74e1de",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "id": 4112,
        "label": "vertex",
        "type": "vertex",
        "properties": {}
      }
    ],
    "meta": {}
  }
}
$ curl https://ibmgraph/11/g/vertices/4112 -XPOST -Hcontent-type:application/json -d '{"languages":"Node"}' | jq .
{
  "requestId": "52ad6d49-46c9-41aa-9928-5a567099d773",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "id": 4112,
        "label": "vertex",
        "type": "vertex",
        "properties": {
          "languages": [
            {
              "id": "si-368-sl",
              "value": "Node"
            }
          ]
        }
      }
    ],
    "meta": {}
  }
}
$ curl https://ibmgraph/11/g/vertices/4112 -XPOST -Hcontent-type:application/json -d '{"languages":"Python"}' | jq .
{
  "requestId": "19886949-6328-4e19-8cac-8fdab37ef2a5",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "id": 4112,
        "label": "vertex",
        "type": "vertex",
        "properties": {
          "languages": [
            {
              "id": "si-368-sl",
              "value": "Node"
            },
            {
              "id": "16q-368-sl",
              "value": "Python"
            }
          ]
        }
      }
    ],
    "meta": {}
  }
}

问题在于,您试图创建一个数据类型为
List
的单个顶点属性,这在IBM Graph中不受支持(仅支持JSON基元类型)。要利用具有
数据类型的属性,需要创建多个顶点属性

事实证明,TinkerPop中基数和数据类型之间的区别可能有点混淆。这里有一个例子可以说明问题:

$ curl https://ibmgraph/11/g/schema -XPOST -Hcontent-type:application/json -d '{"propertyKeys":[{"name":"languages","dataType":"String","cardinality":"SET"}]}' | jq .
{
  "requestId": "9e0ea947-f9a1-407b-ab1a-cd9b7fd5d561",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "propertyKeys": [
          {
            "name": "languages",
            "dataType": "String",
            "cardinality": "SET"
          }
        ],
        "vertexLabels": [],
        "edgeLabels": [],
        "vertexIndexes": [],
        "edgeIndexes": []
      }
    ],
    "meta": {}
  }
}
$ curl https://ibmgraph/11/g/vertices -XPOST | jq .
{
  "requestId": "2ce85907-2aca-4630-876f-31775e74e1de",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "id": 4112,
        "label": "vertex",
        "type": "vertex",
        "properties": {}
      }
    ],
    "meta": {}
  }
}
$ curl https://ibmgraph/11/g/vertices/4112 -XPOST -Hcontent-type:application/json -d '{"languages":"Node"}' | jq .
{
  "requestId": "52ad6d49-46c9-41aa-9928-5a567099d773",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "id": 4112,
        "label": "vertex",
        "type": "vertex",
        "properties": {
          "languages": [
            {
              "id": "si-368-sl",
              "value": "Node"
            }
          ]
        }
      }
    ],
    "meta": {}
  }
}
$ curl https://ibmgraph/11/g/vertices/4112 -XPOST -Hcontent-type:application/json -d '{"languages":"Python"}' | jq .
{
  "requestId": "19886949-6328-4e19-8cac-8fdab37ef2a5",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {}
  },
  "result": {
    "data": [
      {
        "id": 4112,
        "label": "vertex",
        "type": "vertex",
        "properties": {
          "languages": [
            {
              "id": "si-368-sl",
              "value": "Node"
            },
            {
              "id": "16q-368-sl",
              "value": "Python"
            }
          ]
        }
      }
    ],
    "meta": {}
  }
}