首页 文章

Fuseki索引(Lucene)文本搜索没有返回任何结果

提问于
浏览
3

我有一个非常大的本体RDF文件(几乎4M实例),我目前通过Fuseki v2.0.0流式传输 . 我的汇编程序文件如下所示:

@prefix :        <#> .
@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 myprefix: <http://www.example.org/some/path/myprefix#> .

## 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 .
# Solr index
text:TextIndexSolr    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 "DB" ;
    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"
# myprefix:foo is mapped to field "text"
<#entMap> a text:EntityMap ;
    text:entityField      "uri" ;
    text:defaultField     "text" ;
    text:map (
         [ text:field "text" ; text:predicate myprefix:foo ]
         ) .

为了在合理的响应时间内对特定元素执行文本搜索,我使用文本索引导入了RDF文件:

$ java -cp $FUSEKI_HOME/fuseki-server.jar tdb.tdbloader --tdb=run/text-config.ttl ontologies.rdf

......和

$ java -cp $FUSEKI_HOME/fuseki-server.jar jena.textindexer --desc=run/text-config.ttl

...然后运行Fuseki服务器

./fuseki-server -v --debug -loc=DB /dataset

导入过程中没有错误,我可以针对这个新数据集运行各种SPARQL查询,没有任何问题 . 但是当我尝试执行全文查询时,我得到0结果:

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
PREFIX text: <http://jena.apache.org/text#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix myprefix: <http://www.example.org/some/path/myprefix#>

SELECT ?s ?sci_name
{ ?s text:query (myprefix:foo '123test' 10) ; 
    myprefix:foo ?sci_name 
}

我错过了一些明显的东西吗?即使设置了详细和调试标志,我也看不到Fuseki服务器日志上的警告或错误 . 我可以执行常规的SPARQL查询来获得相同的结果,但它(可以理解)非常慢:

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
PREFIX text: <http://jena.apache.org/text#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix myprefix: <http://www.example.org/some/path/myprefix#>

SELECT ?s
{ ?s myprefix:foo ?o .
  FILTER regex(str(?o), "123test", "i")
}

任何有关这方面的帮助都会受到赞赏,因为我是Fuseki / Jena的新手而且我已经走到了尽头 .

1 回答

  • 4

    如果您运行服务器

    ./fuseki-server -v --debug -loc=DB /dataset
    

    那么它没有使用你的配置文件 . 尝试:

    ./fuseki-server --desc text-config.ttl
    

    或者更好地拥有一个带有服务和数据集描述的Fuseki配置文件(参见示例)并运行:

    ./fuseki-server --confg config.ttl
    

相关问题