ローカルの Fuseki SPARQL エンドポイントを使用して、Jena TDB ストアでかなり高速に実行される単純な SPARQL クエリがあります。
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
次に、答えがすぐに表示され、前に示したオブジェクト プロパティの 1 つだけが表示されることを期待します。結局のところ、これは前のクエリをさらに改良しただけです。ただし、クエリには何倍もの時間がかかり、数秒ではなく数分後に終了します。
ここで戸惑います。2 番目のクエリに時間がかかるのはなぜですか?
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 ;
.