【发布时间】:2015-06-05 11:19:01
【问题描述】:
我正在学习将 Gremlin 与 MongoDB 结合使用。我想从一个名为 Project 的 mongo 数据库开始创建一个图 neo4j。
import com.gmongo.GMongo
gremlin> mongo = new GMongo()
==>com.gmongo.GMongo@5c08c46a
gremlin> db = mongo.getDB("Project")
==>DB{name='Project'}
gremlin> Graph graph = new Neo4jGraph("/tmp/my_graph");
==>neo4jgraph[EmbeddedGraphDatabase [\tmp\my_graph]]
现在我可以在 Gremlin shell 上使用 mongo 命令了。
项目数据库有一个名为team的集合。这是一份团队收藏的文件:
{
"_id" : "Juv.35",
"official_name" : "Juventus Football Club S.p.A.",
"common_name" : "Juventus",
"country" : "Italy",
"started_by" : {
"day" : 1,
"month" : 11,
"year" : 1897
},
"stadium" : {
"name" : "Juventus Stadium",
"capacity" : 41011
},
"palmarès" : {
"Serie A" : 33,
"Coppa Italia" : 10,
"Supercoppa Italiana" : 6,
"UEFA Champions League" : 3,
"UEFA Europa League" : 3,
"UEFA Super Cup" : 2,
"UEFA Intertoto cup" : 1,
"Cup Winners cup" : 1,
"UEFA Intercontinental cup" : 2
},
"uniform" : "black and white"
}
现在我想向包含尤文图斯信息的变量图添加一个顶点。 我试试这个:
gremlin> graph.addVertex([db.team.find({common_name:'Juventus'})])
但它不起作用。 (我无法找到有关此主题的文档)如何添加此顶点?
【问题讨论】: