Using the Old Neo4j Database with Grails

I would like to use the ENRON GraphML dataset loaded in Neo4j as the database for my Grails 2.0 application. The use case for data is read-only. I had no problems loading the dataset and creating the database in a separate application, and now we would like to use the Grails plugin to control access to the database.

Looking at the Neo4J plugin documentation for matching domain classes, I see that for each type of vertex, subtree nodes are required. My data does not have this. I see several ways to move forward, and I'm not sure what to pursue:

  • Reset the plugin, create a service, and independently control the reading of the database. Pros: I can implement this easily. Cons: potential performance problems, errors.

  • Write a program that creates the missing vertices and edges expected by the plugin, and then load the database into the plugin. Pros: the plugin will control access. Cons: You can do several iterations to determine exactly what needs to be added so that they match the database created by the plugins.

  • Create an empty database through the plugin and do a bunch of inserts while reading data from another database. Pros: the plugin will control access. Cons: it may take a long time to load the database; you must write code to move, serialize the database; and etc.

What a good way to go? What am I missing?

+1
source share
1 answer

As the author of the Grails Neo4j plugin, I can give a qualified answer here. The subtree structure currently used in the plugin is not always the best approach. I have plans to replace this by indexing in a custom way, but right now there is no ETA. Since you may need a shorter-term solution, I suggest choosing between 1) and 2) in the case of a read-only database. One of the main advantages of using domain classes is the use of forests. As you are only reading, this argument is not considered IMHO here.

1) has another nice advantage: if you use, for example, cypher to request a graph, the performance will be very good even when using a REST-style database. In general, if performance is important, you should use cypher in favor of querying Grails criteria / dynamic crawlers.

2) If you are going with this approach, I can provide some support. Basically you need to create your domain classes and create a subsequence node for each domain class and associate all instances with this. The advantage here: you can use, for example. dynamic crawlers or standard query criteria. Creating subreference nodes and connections to node instances could be easily accomplished with one or two cypher statements.

+1
source

Source: https://habr.com/ru/post/1443335/


All Articles