Reputation: 19
I would like to query a MonboDB instance via the GraphDB SPARQL query interface.
Currently I am using a GraphDB 8.9 Free instance and MongoDB 4.0.8 without a password on the default ports and on the same host (none of the ports are open to the outside). I followed the instructions at http://graphdb.ontotext.com/documentation/free/integrating-graphdb-with-mongodb.html.
This is the query from the documentation:
PREFIX cwork: <http://www.bbc.co.uk/ontologies/creativework/>
PREFIX inst: <http://www.ontotext.com/connectors/mongodb/instance#>
PREFIX : <http://www.ontotext.com/connectors/mongodb#>
SELECT ?creativeWork ?modified WHERE {
?search a inst:spb1000 ;
:find '{"@graph.cwork:audience.@id" : "cwork:NationalAudience"}' ;
:entity ?entity .
GRAPH inst:spb1000 {
?creativeWork cwork:dateModified ?modified .
}
}
Creating the index was apparently successful:
[INFO ] 2019-04-05 14:01:53,036 [repositories/playground-default | c.o.g.s.StatementsController] POST SPARQL update request to repository
[INFO ] 2019-04-05 14:01:53,044 [repositories/playground-default | c.o.p.mongodb] Creating a new service in MongoDB: spb1000
[INFO ] 2019-04-05 14:01:53,045 [repositories/playground-default | c.o.p.mongodb] Setting connectionString for MongoDB service spb1000
[INFO ] 2019-04-05 14:01:53,045 [repositories/playground-default | c.o.p.mongodb] Setting database for MongoDB service spb1000
[INFO ] 2019-04-05 14:01:53,045 [repositories/playground-default | c.o.p.mongodb] Setting collection for MongoDB service spb1000
But then the example query from the documentation did not work. GraphDB output 0 results and the console shows the following messages:
[INFO ] 2019-04-05 14:02:13,158 [repositories/playground-default | c.o.f.s.RepositoryController] POST query -563697573
[ERROR] 2019-04-05 14:02:13,160 [repositories/playground-default | c.o.p.mongodb] iter not created yet
[ERROR] 2019-04-05 14:02:13,160 [repositories/playground-default | c.o.p.mongodb] iter not created yet
[ERROR] 2019-04-05 14:02:13,161 [repositories/playground-default | c.o.t.q.OwlimEvaluationStrategyImpl] Couldn't convert the query to our optimized model. Using sesame's query model
java.lang.NullPointerException: null
[...]
I should get more than 10 results, but currently I get nothing. It seems somehow GraphDB could not generate a MongoDB query. Since I used/copied the SPARQL query from the documentation this should be possible.
Upvotes: 0
Views: 435
Reputation: 611
Because mongodb plugin doesn't present in 8.6 version of GraphDB when you upgrade to 8.9 version on start PluginManager detects that latter isn't in fingerprint and disables it to protect cluster integrity. First you should enable it using the following Sparql query:
"insert data { [] <http://www.ontotext.`com`/owlim/system#startplugin> "mongodb" }",
afterwards you should create plugin into upgraded repository using query that is in the documentation or:
"PREFIX : <http://www.ontotext.com/connectors/mongodb#>
PREFIX inst: <http://www.ontotext.com/connectors/mongodb/instance#>
INSERT DATA {
inst:spb1000 :service "mongodb://localhost:27017" ;
:database "ldbc" ;
:collection "creativeWorks" .
}"
you shouldn't delete the database or collection in MongoDB.
Upvotes: 1
Reputation: 1142
As a conclusion fro the previous comments - it's always advisable to rebuild the connectors after migrating to newer version, since depending on the version you might need to make a changes in the connector.
Upvotes: 0