GraphSONを使用したデータの挿入
GraphSONを使用してグラフ・データベースにデータを挿入する方法。
GraphSONは、IDとラベル、外向きエッジと内向きエッジ、プロパティを持つ頂点を定義するJSONデータです。
手順
-
頂点IDとラベルを識別します。
{ "id":{"~label":"author","member_id":35,"community_id":1733329920}, label":"author",各頂点に識別子が1つ必要です。通常、ラベルは頂点のタイプを示すよう定義されます。この例で示されている頂点は
author頂点です。 -
頂点プロパティを識別します。
"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、値で識別されます。この例は、
Simone Beckという値とFというgender値を持つ作者名nameを示しています。 -
外向きエッジを追加します。
"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が1つずつ必要です。この例は
authoredエッジを示しています。この例で示す外向きエッジの場合は、内向きインデックスinVを頂点IDで識別する必要があります。 - サフィックス「.json」を使用して、GraphSONファイルに名前を付けて閉じます。
