鉴于这个非常简单的模型:
@prefix : <http://example.org/tags#> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
:tag rdf:type rdf:Property .
:item1
rdf:type owl:Thing ;
:tag "a"^^xsd:string .
:item2
rdf:type owl:Thing ;
:tag "a"^^xsd:string , "b"^^xsd:string .
:item3
rdf:type owl:Thing ;
:tag "a"^^xsd:string , "b"^^xsd:string , "c"^^xsd:string .
Run Code Online (Sandbox Code Playgroud)
我想获得每个项目的列表和标签数量:
item tagCount
===== ========
item1 1
item2 2
item3 3
Run Code Online (Sandbox Code Playgroud)
这是我的查询:
SELECT ?item (count(?tag) as ?tagcount)
WHERE {
?item :tag ?tag
}
Run Code Online (Sandbox Code Playgroud)
然而它正在回归:
item tagCount
===== ========
6
Run Code Online (Sandbox Code Playgroud)
从我所读到的,这应该工作.我正在使用Jena 2.6.4