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

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

问题描述

我正在研究推荐引擎.收集用户数据(他们的友谊、位置、喜欢、教育等)并已存储在 mongodb 中.我需要向这些用户推荐相关产品.出于显而易见的原因(易于在节点之间遍历、路径信息等),我计划将 Neo4j 用于推荐引擎.问题是我必须首先将 mongodb 数据转换为 neo4j 节点/关系,处理数据并将结果发送回 mongodb 数据库.主要的问题是我们最终会维护两个数据库,这让开发团队不高兴.我已经看过类似的帖子 mongodb-neo4jspring data 但不确定如何解决这个问题.这些是我的问题
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- 下载 GmongoJava mongo 驱动程序
2-复制neo4j/lib目录下的两个jar文件
3- 这是一个例子.假设我们在 mongodb 中有这个集合(称为以下)

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 shell 运行以下命令.

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天全站免登陆