将mongodb与neo4j集成,是否有任何API可以链接它们? [英] Integrating mongodb with neo4j, is there any API that will link them?

查看:104
本文介绍了将mongodb与neo4j集成,是否有任何API可以链接它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究推荐引擎.收集用户数据(他们的友谊,位置,喜欢,教育等),并已将其存储在mongodb中.我需要向这些用户推荐相关产品.由于明显的原因(在节点之间易于遍历,路径信息等等),我正计划将neo4j用于推荐引擎.问题是我必须首先将mongodb数据转换为neo4j节点/关系,处理数据,然后将结果发送回mongodb数据库.主要问题是,我们最终将维护两个数据库,而这对于开发团队来说是不满意的.我已经看过类似的帖子 mongodb-neo4j spring数据,但不确定如何解决此问题. 这些是我的问题
1-仅仅为了推荐引擎(我们正在处理大型网络)而添加另一个数据库是值得的,尽管neo4j非常适合此类任务.
2-我使用cypher进行查询,对java,rest API和spring数据了解不多.我应使用哪种API进行mongodb-neo4j通信?我当前的解决方案是使用R并将其用作连接到mongodb和neo4j的平台.
3-关于其他图形数据库,是否有适合与Mongo集成的数据库?

I am working on a recommendation engine. The user data is collected (Their friendship, locations, likes,education,...) and is already stored in mongodb. I need to recommend relevant products to these users. I am planning on using neo4j for the recommender engine for obvious reasons (ease of traversal between nodes, path information,..). The problem is that I have to first convert the mongodb data into neo4j nodes/relationships, process the data and send the results back to the mongodb database. The main problems is that we will end up maintaining two databases, something that the development team will not be happy. I have already looked into similar posts mongodb-neo4j and spring data but not sure what to make of them for this problem. these are my questions
1- Is it worth it to add another DB just for the sake of a Recommendation engine(we are dealing with a large network), although neo4j is a perfect fit for such task.
2- I am using cypher for queries and don't know much about java, rest API and spring data. What kind of API should I use for mongodb-neo4j communications? My current solution is to use R and use it as the platform to connect to both mongodb and neo4j.
3- How about other graph databases, is there one that is ore fit to integrate with Mongo?

推荐答案

我发现了两种整合mongodb和Neo4j的方法.第一个建议由 ryan1234 使用Gremlin和Gmongo共同提出.根据这个出色的博客
1-下载 Gmongo

I found two ways to integrate mongodb and Neo4j. The first one was suggested by ryan1234 using Gremlin together with Gmongo. The steps are as following according to this excellent blog
1- Download Gmongo and Java mongo driver
2- copy the two jar files under neo4j/lib directory
3- This is an example. suppose we have this collection (called follows) in mongodb

{ "_id" : ObjectId("4ff74c4ae4b01be7d54cb2d3"), "followed" : "1", "followedBy" : "3", "createdAt" : ISODate("2013-01-01T20:36:26.804Z") }
{ "_id" : ObjectId("4ff74c58e4b01be7d54cb2d4"), "followed" : "2", "followedBy" : "3", "createdAt" : ISODate("2013-01-15T20:36:40.211Z") }
{ "_id" : ObjectId("4ff74d13e4b01be7d54cb2dd"), "followed" : "1", "followedBy" : "2", "createdAt" : ISODate("2013-01-07T20:39:47.283Z") }

在Neo4j的Gremlin外壳程序中,运行以下命令.

from the Gremlin shell in Neo4j run the following commands.

import com.gmongo.GMongo
mongo = new GMongo() 
db = mongo.getDB("local")
db.follows.findOne().followed
x=[] as Set; db.follows.find().each{x.add(it.followed); x.add(it.followedBy)}
x.each{g.addVertex(it)}
db.follows.find().each{g.addEdge(g.v(it.followedBy),g.v(it.followed),'follows',[followsTime:it.createdAt.getTime()])} 

就是这样,我们已经在neo4j中创建了等效图

and that is it we have created the equivalent graph in neo4j

这篇关于将mongodb与neo4j集成,是否有任何API可以链接它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆