Ale*_*x W 1 sparql marklogic marklogic-8
使用以下示例三元组:
@prefix : <http://www.me.org/me_schema#> .
@prefix dc: <http://purl.org/dc#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://www.me.org/content/me_schema>
rdf:type owl:Ontology ;
owl:imports <http://www.w3.org/2004/02/skos/core> ;
.
:a
rdf:type owl:ObjectProperty ;
rdfs:label "A" ;
rdfs:subPropertyOf :b ;
.
:b
rdf:type owl:ObjectProperty ;
rdfs:label "B" ;
rdfs:subPropertyOf :c ;
.
:c
rdfs:label "C"^^xsd:string ;
.
Run Code Online (Sandbox Code Playgroud)
此查询按预期返回两行(列和?中的b和c):
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
from <test>
where
{
?s rdfs:label 'A' .
?s rdfs:subPropertyOf+ ?o
}
Run Code Online (Sandbox Code Playgroud)
但是,我希望以下内容返回1行,但它返回空结果.在查询控制台中测试:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
from <test>
where
{
?s rdfs:label 'A' .
?s rdfs:subPropertyOf+ <http://www.me.org/me_schema#c>
}
Run Code Online (Sandbox Code Playgroud)
我希望它为"a"返回一行.这是一个错误还是我错过了一些明显的东西?
我尝试使用DBPedia进行类似的查询,它似乎按照我的预期返回数据.例如,以下查询返回"star"的两行,尽管两者都不是直接的subClassOf owl:Thing.
select *
where
{
?s rdfs:label "star"@en .
?s rdfs:subClassOf+ owl:Thing
} LIMIT 100
Run Code Online (Sandbox Code Playgroud)
如果有人遇到同样的问题,我想出了以下工作:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
from <test>
where
{
?s rdfs:label 'A' .
?s rdfs:subPropertyOf ?s2 .
?s2 rdfs:subPropertyOf* <http://www.me.org/me_schema#c>
}
Run Code Online (Sandbox Code Playgroud)
(我会把它放在评论中,但我没有这样做的声誉.)
我刚刚在MarkLogic 8.0-3上尝试过你的null结果示例,我确实得到了[{"s":"<http://www.me.org/me_schema#a>"}],正如你所期望的那样.您使用的是早期版本的MarkLogic(您可以在左上角看到该版本localhost:8001)?
为了验证这一点,我去MarkLogic查询控制台的localhost:8000/qconsole/,设置了"内容源"到我的数据库(与三联指数开启)更改查询类型设置为"SPARQL更新",并进入该SPARQL插入代码:
PREFIX : <http://www.me.org/me_schema#>
prefix dc: <http://purl.org/dc#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
INSERT DATA { GRAPH <test> {
<http://www.me.org/content/me_schema> rdf:type owl:Ontology .
<http://www.me.org/content/me_schema> owl:imports <http://www.w3.org/2004/02/skos/core> .
:a rdf:type owl:ObjectProperty .
:a rdfs:label "A" .
:a rdfs:subPropertyOf :b .
:b rdf:type owl:ObjectProperty .
:b rdfs:label "B" .
:b rdfs:subPropertyOf :c .
:c rdfs:label "C"^^xsd:string .
}}
Run Code Online (Sandbox Code Playgroud)
然后,我在查询控制台中打开了一个新选项卡,将查询类型设置为"SPARQL查询",并运行您的确切查询:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
from <test>
where
{
?s rdfs:label 'A' .
?s rdfs:subPropertyOf+ <http://www.me.org/me_schema#c>
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是早期版本的MarkLogic,请尝试在MarkLogic下载页面上更新到最新版本.
| 归档时间: |
|
| 查看次数: |
112 次 |
| 最近记录: |