GraphSONを使用したデータの挿入

GraphSONを使用してグラフ・データベースにデータを挿入する方法。

GraphSONは、そのIDとラベル、外向きおよび内向き辺、プロパティによって頂点を定義するJSONデータです。

手順

  1. 頂点IDとラベルを特定します。
    {
    "id":{"~label":"author","member_id":35,"community_id":1733329920}, 
    label":"author",

    各頂点には識別子が必要です。通常、ラベルは頂点のタイプを示すために定義されます。この例に示した頂点は、author(著者)頂点です。

  2. 頂点のプロパティを特定します。
    "properties":{"gender":[{
    "id":{
    "local_id":"00000000-0000-8084-0000-000000000000",
    "~type":"gender",
    "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920}},
    "value":"F"
        }],
    "name":[{
    "id":{
    "local_id":"00000000-0000-8083-0000-000000000000",
    "~type":"name",
    "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920}},
    "value":"Simone Beck"}]
    }}

    各プロパティは名前、ID、および値で指定します。この例では、著者名nameが示されています。その値はSimone Beckで、genderの値としてFを持ちます。

  3. 外向け辺を追加します。
     "outE":{
    "authored":[{
    "id":{
    "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920},
    "local_id":"72086b3c-0e6c-11e6-b5e4-0febe4822aa4",
    "in_vertex":{"~label":"book","member_id":52,"community_id":1733329920},
    "~type":"authored"
          },
    "inV":{"~label":"book","member_id":52,"community_id":1733329920}}, {
    "id":{
    "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920},
    "local_id":"72086b32-0e6c-11e6-b5e4-0febe4822aa4",
    "in_vertex":{"~label":"book","member_id":54,"community_id":1733329920},
    "~type":"authored"
          },
    "inV":{"~label":"book","member_id":54,"community_id":1733329920}}]},

    各辺にはラベルとIDが必要です。この例はauthored辺を示しています。例に示したように、外向き辺の場合、頂点IDにより内向き頂点inVを指定する必要があります。

  4. ".json"のサフィックスを使用して名前を付け、GraphSONファイルを閉じます。