在Grails中使用传统的Neo4j数据库 [英] Using a legacy Neo4j database with Grails

查看:72
本文介绍了在Grails中使用传统的Neo4j数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 ENRON GraphML数据集,加载到Neo4j中,作为我的Grails 2.0应用程序的数据库。数据的用例是只读的。我在加载数据集并在独立应用程序中创建数据库方面没有问题,现在想使用Grails插件来管理对数据库的访问。



查看 Neo4J插件文档关于映射域类,我看到它需要每个类型顶点的子引用节点。我的数据没有。我可以看到几种前进的方式,并且不确定要追求哪种方式:


  1. 转储插件,创建服务,并管理自己阅读数据库。优点:我可以轻松实现。缺点:潜在的性能问题,错误。
    编写一个程序,创建插件所期望的缺失顶点和边,然后将数据库加载到插件中。优点:插件将管理访问。缺点:可能需要进行一些迭代,以确定需要添加什么才能使其与创建插件的数据库保持一致。

  2. 通过通过插件创建的数据库创建一个空数据库该插件通过读取不同数据库中的数据来执行一堆插入。优点:插件将管理访问。缺点:可能需要很长时间来引导数据库;需要编写代码遍历,序列化数据库;

最好的方法是什么?我在忽略什么?

解决方案

作为Grails Neo4j插件的作者,我可能会在这里给出一个合格的答案。插件中目前使用的子参照结构并不总是最好的方法。我有一些计划可以通过可配置的索引来取代这一点,但现在没有ETA。
因为您可能需要更短期的解决方案,所以如果是只读数据库,我建议在1)和2)之间进行选择。使用域类的主要优点之一是使用脚手架。因为你只是阅读,这个论点不算在这里恕我直言。



1)有另一个好处:如果你使用例如即使在使用REST风格的数据库时,cypher查询图表的性能也会非常好。一般来说,如果性能很重要,你应该使用密码来支持Grails标准查询/动态查找。


$ b 2)如果你打算用这种方法,我可以提供一些支持。基本上,您需要创建您的域类,并为每个域类创建一个子参照节点,并将所有实例连接到此类。这里的优势:您可以使用例如动态查找器或标准条件查询。创建子参照节点和与实例节点的连接可以通过一个或两个密码语句轻松完成。


I would like to use the ENRON GraphML dataset, loaded into Neo4j, as a database for my Grails 2.0 application. The use-case for the data is read-only. I have had no trouble loading the dataset and creating a database in a stand-alone application, and now would like to use the Grails plugin to manage access to the database.

Looking at the Neo4J plugin documentation on mapping domain classes, I see that it requires subreference nodes for each type of vertex. My data doesn't have that. I can see several ways of moving forward, and am unsure about which to pursue:

  1. Dump the plugin, create a service, and manage reading the database myself. Pros: I can implement this easily. Cons: potential performance issues, bugs.

  2. Write a program that creates the missing vertexes and edges expected by the plugin, and then load the database into the plugin. Pros: plugin will manage access. Cons: Might take a few iterations to figure out exactly what needs to be added to make it consistent with a plugin-created database.

  3. Create an empty database via the plugin and perform a bunch of insertions by reading the data from a different database. Pros: plugin will manage access. Cons: might take a long time to bootstrap database; need to write code to traverse, serialize database; etc.

What's a good way to go? What am I overlooking?

解决方案

As being the author of the Grails Neo4j plugin I might be able to give a qualified answer here. The subreference structure currently used in the plugin is not always the best approach. I have some plans to replace this by indexing in a configurable way but there is no ETA right now. As you might require a more short term solution, I suggest to choose between 1) and 2) in case of a read-only database. One of the main advantages for using domain classes is the usage of scaffolding. As you're read only, this argument does not count here IMHO.

1) has another nice advantage: If you use e.g. cypher to query the graph the performance would be very good even when using a REST style database. In general if performance is important you should use cypher in favour of doing Grails criteria queries/ dynamic finders.

2) If you're going with that approach I can provide some support. Basically you need to create your domain classes and create a subreference node per domain class and connect all instances to this one. Advantage here: you could use e.g. dynamic finders or standard criteria queries. Creating the subreference nodes and the connections to the instances node could be easily done with one or two cypher statements.

这篇关于在Grails中使用传统的Neo4j数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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