我想通过GraphDB SPARQL查询界面查询MonboDB实例。
当前,我在默认端口和同一主机上使用GraphDB 8.9 Free实例和MongoDB 4.0.8,而没有密码(没有端口对外开放)。我按照http://graphdb.ontotext.com/documentation/free/integrating-graphdb-with-mongodb.html上的说明进行操作。
这是来自文档的查询:
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 .
}
}
创建索引显然是成功的:
[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
但是,文档中的示例查询不起作用。 GraphDB输出0个结果,并且控制台显示以下消息:
[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
[...]
我应该得到10个以上的结果,但是目前我什么也没得到。 似乎GraphDB无法以某种方式生成MongoDB查询。 由于我使用/从文档中复制了SPARQL查询,因此应该可以。
答案 0 :(得分:1)
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.
答案 1 :(得分:0)
作为先前评论的结论-始终建议在迁移到较新版本后重建连接器,因为根据版本的不同,您可能需要在连接器中进行更改。