Ancelot182
Ancelot182

Reputation: 149

Sparql Plugin usage

I'm testing Neo4J to compare it to the EA platform my company have used in this years. This platform relays on a MySQL database that we're querying with SPARQL/SPARUL. Except for the SPARUL support (that is not mandatory at this moment) the idea was to replace this MySQL database with Neo4J and test if it's advantageous to query it with directly with SPARQL or if it's better to translate SPARQL query in cypher and tests like that.

Since i was having some problem with the SPARQL plugin of Neo4J2 i switched back to 1.9.7. I have populated a testdb with some data imported from an .nt file, but when i use my advanced rest client for chrome to query them i don't get the result i hope. A simple query like this

{
    "query" : "SELECT ?x ?y WHERE { ?x <http://neo4j.org#RUN_ON> ?y . }"
}

doesn't return nothing. When i insert data through SPARQL plugin via the insert_quad, for example with a query like

  "s" : "http://neo4j.org#Application_process_1",
  "p" : "http://neo4j.org#RUN_ON",
  "o" : "http://neo4j.org#Database_3",
  "c" : "http://neo4j.org"

instead it works.

I've noticed that in this case the composition of the nodes and the relationships is different from what i get when i create a node via Java API (the relationship for example has 3 properties: cp,c,p that mine don't have)

Do I have to insert all the data via plugin in a database to query it via SPARQL ? Can i do this via Java API so that i can for example use a parser on a file and create a query for every line I read? (something like inserting some mandatory properties for each kind of resource). Otherwise there's a way to load multiple data via SPARQL plugin in neo4j without write them all ? (something like a for on file entries to be clear)

Thx for the help.

EDIT: I'm not interested in using another tecnology that perform better with SPARQL. I just wanna now if the SPARQL plugin for Neo4j allows me to do something like multiple insert in a programmatic way, or if i'm force to use it to insert data into a graph that i wanna query with the plugin itself. The point is, if possible, to use SPARQL and test the performance of certain complex query and evaluate various factors against the old solution using a relational db and a solution that uses just the native API (or Cypher) of Neo4j.

Upvotes: 0

Views: 255

Answers (1)

Jerven
Jerven

Reputation: 602

Are you sure you want to do this? While NEO4j is nice there are so many other production quality SPARQL solutions out there. That I can't recommend a non standard (sparql http protocol wise), non vendor supported plugin as valid technical solution.

You are moving from one of the SPARQL on top of MySQL solutions, that was state of the art in 2010 but not competitive (or maintained) these days.

I suggest you look at Virtuoso or something from the OWLIM family instead. If your data not very large (a few million triples) then the solutions from apache jena or open rdf sesame(this is used inside the sparql plugin as well) fit your needs. Scaling wise Systap Bigdata also beat Neo4j performance in my tests.

I am listing mostly java based solutions as you are ok with that seeing Neo4j is one as well.

In other words look at upgrading to a real SPARQL solution or rewriting for Cypher and Neo4j.

Now to your actual question. As you are introducing a context or named graph when loading data you might need to use that in your query as well.

{
    "query" : "SELECT ?x ?y 
               WHERE { GRAPH<http://neo4j.org>{?x <http://neo4j.org#RUN_ON> ?y . }}"
}

However, a key thing for your customer is that they are probably using sparql over http to access your data. This is exactly where Neo4j sparql is incompatible i.e. neo4jsparql expects a json string while sparql http expects a uri parameter called query.

I now think I better understand your question. You used the Neo4J api directly to insert nodes into a neo4j graph. Then you try to use the SPARQL plugin to query over those nodes you inserted. This does not work, as the SPARQL plugin expects a certain graph structure to exist. You either need to carefully study the graph generated by the SPARQL plugin and recreate it exactly or use the: com.tinkerpop.blueprints.oupls.sail.GraphSail addStatement to do so correctly for you.

Upvotes: 1

Related Questions