Fuseki config for 2 datasets + text index : how to

2019-06-07 19:25发布

I'm new to fuseki and want to use 2 TDB datasets for our project : a small one for our own data, and a large one (168 M triples, imported data from http://data.bnf.fr).

We need to index the data because SPARQL queries using "FILTER(CONTAINS())" don't work on the large dataset ("BnF_text"). Therefore, I've built a text index for "BnF_text", following this post : Fuseki indexed (Lucene) text search returns no results (but I had to modify the turtle config file to get the text:query working).

It works, but I've encountered a strange problem with "BnF_text" : from time to time, the same query returns a timeout, and I can't see find error in fuseki logs nor apache logs.

~~~~~~~ Here are my questions : ~~~~~~~

  • is there a problem with my config files?
  • is the performance affected by the coexistence of 2 datasets?

~~~~~~~ Here are the details of my installation : ~~~~~~~

  • modified Java memory limit in script fuseki-server : set to --Xmx4000M .
  • SPARQL queries are sent via PHP EasyRDF library
  • I have 2 config files : $FUSEKI_PATH/text_config.ttl + $FUSEKI_PATH/run/configuration/MY_DATASET.ttl
  • I run fuseki-server with this command : ./fuseki-server --config text_config.ttl

Config files

1) text_config.ttl

@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 fuseki:  <http://jena.apache.org/fuseki#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .

## 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 :tdb_dataset_readwrite ;
    text:index     <#indexLucene> ;
    .

# A TDB datset used for RDF storage ------------------------------
:tdb_dataset_readwrite                    # <= EDIT : instead of <#dataset>  
        a             tdb:DatasetTDB ;
        tdb:location  "TDB_PATH" ;
.

# Text index description ------------------------------------------
<#indexLucene> a text:TextIndexLucene ;
    text:directory <file:LUCENE_PATH> ;
    text:entityMap <#entMap> ;
    text:storeValues true ;
    .

# Mapping in the index ---------------------------------------------
# URI stored in field "uri" 
<#entMap> a text:EntityMap ;
    text:entityField      "uri" ;
    text:defaultField     "text" ;
    text:map (
         [ text:field "text" ; text:predicate dcterms:title ]
         [ text:field "text" ; text:predicate foaf:familyName ]
         [ text:field "text" ; text:predicate foaf:name ]
         ) .

# Fuseki services (http) --------------------------------------------- 

# EDIT : added following lines

:service_tdb_all  a                   fuseki:Service ;
        rdfs:label                    "TDB BnF_text" ;
        fuseki:dataset                :text_dataset ; ### 
        fuseki:name                   "BnF_text" ;
        fuseki:serviceQuery           "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadWriteGraphStore " .

2) MY_DATASET.ttl

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

:service_tdb_all  a                   fuseki:Service ;
        rdfs:label                    "TDB MY_DATASET" ;
        fuseki:dataset                :tdb_dataset_readwrite ;
        fuseki:name                   "MY_DATASET" ;
        fuseki:serviceQuery           "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadWriteGraphStore
                "data" ;
        fuseki:serviceUpdate          "update" ;
        fuseki:serviceUpload          "upload" .

:tdb_dataset_readwrite
        a             tdb:DatasetTDB ;
        tdb:location  "MY_DATASET_TDB_PATH" .

Thanks in advance

1条回答
女痞
2楼-- · 2019-06-07 19:40

Thanks Andy, you were right. The problem came from EasyRDF and not from Fuseki. I found this : https://groups.google.com/d/msg/skosmos-users/WhtZwnsxOFs/MtAocr8vDgAJ , so changed timeout in vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Client.php, and everything seems to be ok now. I'm going to make a few more tests and then try to mark the question as solved.

EDIT: 'everything seems to be ok now' = the "timeout" message from EasyRdf_Exception has disappeared

查看更多
登录 后发表回答