简体   繁体   English

在 Scala 中使用 neo4j

[英]Using neo4j with scala

I'm new to both Scala and Neo4j.我是 Scala 和 Neo4j 的新手。 I want to create a Neo4j database using Scala.我想使用 Scala 创建一个 Neo4j 数据库。 Is there any resource where i can find some ready made code for creating nodes, deleting nodes, adding properties, creating indexes and etc.是否有任何资源可以找到一些现成的代码来创建节点、删除节点、添加属性、创建索引等。

Thanks.谢谢。

Actually there are several options it depends on (a) how you want to communicate with neo4j (Rest or not) (b) your runtime environment.实际上有几个选项取决于(a)您希望如何与neo4j(是否休息) (b)您的运行时环境进行通信。

When your application is ok with a REST only communication and you're ok to use ANORM to access your (data).当您的应用程序仅支持 REST 通信并且您可以使用ANORM访问您的(数据)时。 There is a promising driver that is currently good enough to do a plenty of thing using Cypher as request language.有一个很有前途的驱动程序,它目前足以使用 Cypher 作为请求语言做很多事情。 You can find it there ( AnormCypher ) : https://github.com/AnormCypher/AnormCypher .你可以在那里找到它( AnormCypher ): https : //github.com/AnormCypher/AnormCypher The power of ANORM is a source of a lot of debate, but I think it has a lot of good feature. ANORM 的强大功能引起了很多争论,但我认为它有很多好的特性。

There is also the FaKod scala driver which is very complete, and the second version (M1 for now) will include REST capabilities as well.还有非常完整的 FaKod scala 驱动程序,第二个版本(现在是 M1)也将包含 REST 功能。 The power of this driver ( neo4j-scala ) is the clean DSL it provides to abstract traversal internals, it's pretty intuitive and well documented.这个驱动程序 ( neo4j-scala ) 的强大之处在于它为抽象遍历内部提供了干净的 DSL,它非常直观且有据可查。

On the other hand, I had started my driver a while, but didn't had time to put much effort of it (it'll change soon).另一方面,我已经启动了一段时间的驱动程序,但没有时间投入太多精力(它很快就会改变)。 The current version is still rough and tightly coupled to a play application.当前版本仍然粗糙且与播放应用程序紧密耦合。 But this driver tries to use amap the reactivity of future (now akka based) and the json api of play.但是这个驱动程序试图使用 amap 未来的反应性(现在基于 akka)和 play 的 json api。 However, this way shall not be the most productive due to a lack of doc and cleaning... any help is welcome ;-).但是,由于缺乏文档和清洁,这种方式不会是最有效的......欢迎任何帮助;-)。 Also this is a play plugin as well then is pretty easy to configure and inject.这也是一个播放插件,然后很容易配置和注入。

For more information in general regarding drivers, you should go there: http://www.neo4j.org/develop/drivers有关驱动程序的更多信息,您应该去那里: http : //www.neo4j.org/develop/drivers

You might want to have a look at gremlin-scala .您可能想看看gremlin-scala It uses the Tinkerpop stack which is essentially like JDBC for relational databases.它使用 Tinkerpop 堆栈,本质上类似于关系数据库的 JDBC。 You can use it with a number of graph databases including Neo4J.您可以将它与包括 Neo4J 在内的许多图形数据库一起使用。 There are some basic examples on the github page and far more in the gremlin wiki .在 github 页面上有一些基本示例,在gremlin wiki 中有更多示例。

Disclaimer : I'm the maintainer of gremlin-scala ;)免责声明:我是 gremlin-scala 的维护者;)

Have a look at renesca , which lets you use the Neo4j REST API from Scala.查看renesca ,它允许您使用来自 Scala 的Neo4j REST API You can create and modify nodes and relations and persist all your changes at once.您可以立即创建和修改节点和关系并保留所有更改。

For more advanced scenarios check out renesca-magic , which is an abstraction layer on top of renesca.对于更高级的场景,请查看renesca-magic ,它是 renesca 之上的抽象层。 It lets you define powerful type safe graph schemas with as few code as possible.它使您可以使用尽可能少的代码定义强大的类型安全图模式

Some highlights are:一些亮点是:

  • Multiple inheritance of properties属性的多重继承
  • HyperRelations (connect Nodes and Relations) HyperRelations(连接节点和关系)

Disclaimer: I'm a developer of these libraries.免责声明:我是这些库的开发人员。

Neotypes 仍在积极开发中https://github.com/neotypes/neotypes与其他库集成,例如 Akka

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM