1

我有一个简单的 SPARQL 查询,它使用本地 Fuseki SPARQL 端点在我的 Jena TDB 存储上执行得相当快:

SELECT DISTINCT ?p 
WHERE
{ 
  ?s rdf:type dbpedia-owl:Organisation .
  ?s ?p dbpedia:California .
}
LIMIT 10

完成可能需要 10 秒,并且包含一些 owl:ObjectProperty 和其他属性。当我只想使用以下查询显示一个对象属性时(注意最后的附加三元组和 1 的限制):

SELECT DISTINCT ?p 
WHERE
{ 
  ?s rdf:type dbpedia-owl:Organisation .
  ?s ?p dbpedia:California .
  ?p a owl:ObjectProperty .
}
LIMIT 1

那么我希望答案会尽快出现,并且只显示之前显示的对象属性之一。毕竟,这只是对先前查询的进一步细化。但是,查询花费的时间要长很多倍,并且会在几分钟而不是几秒钟后完成。

我在这里感到困惑。为什么第二个查询需要这么长时间?

我正在使用 Fuseki 1.1.0 版。这是我的 fuseki 配置文件:

@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix text:    <http://jena.apache.org/text#> .
@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@prefix foaf:    <http://xmlns.com/foaf/0.1/> .
@prefix :        <http://localhost/dbpedia37#> .

[] rdf:type fuseki:Server ;
   fuseki:services (
     :service_text_tdb
   ) .

## Example of a TDB dataset and text index
## Initialize TDB
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

## Initialize text query
[] ja:loadClass       "org.apache.jena.query.text.TextQuery" .
# A TextDataset is a regular dataset with a text index.
text:TextDataset      rdfs:subClassOf   ja:RDFDataset .
# Lucene index
text:TextIndexLucene  rdfs:subClassOf   text:TextIndex .

## ---------------------------------------------------------------
## This URI must be fixed - it's used to assemble the text dataset.

:text_dataset rdf:type     text:TextDataset ;
    text:dataset   :dataset ;
    text:index     :indexLucene ;
    .

# A TDB datset used for RDF storage
:dataset rdf:type      tdb:DatasetTDB ;
    tdb:location "/Users/jsimon/No-Backup/dbpedia37/tdb" ;
#    tdb:unionDefaultGraph true ; # Optional
    .

# Text index description
:indexLucene a text:TextIndexLucene ;
    text:directory <file:Lucene> ;
    ##text:directory "mem" ;
    text:entityMap :entMap ;
    .

# Mapping in the index
# URI stored in field "uri"
# rdfs:label is mapped to field "text"
:entMap a text:EntityMap ;
    text:entityField      "uri" ;
    text:defaultField     "text" ;
    text:map (
         [ text:field "text" ; text:predicate rdfs:label ]
         [ text:field "text" ; text:predicate foaf:name ]
         ) .

:service_text_tdb rdf:type fuseki:Service ;
    rdfs:label                      "TDB/text service" ;
    fuseki:name                     "ds" ;
    fuseki:serviceQuery             "query" ;
    fuseki:serviceQuery             "sparql" ;
    fuseki:serviceUpdate            "update" ;
    fuseki:serviceUpload            "upload" ;
    fuseki:serviceReadGraphStore    "get" ;
    fuseki:serviceReadWriteGraphStore    "data" ;
    fuseki:dataset                  :text_dataset ;
    .
4

0 回答 0