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

text:TextIndexLucene  rdfs:subClassOf   text:TextIndex .
text:TextDataset      rdfs:subClassOf   ja:RDFDataset .

## ---------------------------------------------------------------
## Updatable TDB2 dataset with all services enabled.

<#service_{NAME}> rdf:type fuseki:Service ;
    rdfs:label                         "TDB2 {NAME}" ;
    fuseki:name                        "{NAME}" ;
    fuseki:serviceQuery                "" ;
    fuseki:serviceQuery                "sparql" ;
    fuseki:serviceQuery                "query" ;
    fuseki:serviceUpdate               "" ;
    fuseki:serviceUpdate               "update" ;
    fuseki:serviceUpload               "upload" ;
    fuseki:serviceReadWriteGraphStore  "data" ;
    fuseki:serviceReadWriteGraphStore  "" ;
    fuseki:serviceReadGraphStore       "get" ;
    fuseki:dataset                     <#lucene_dataset_{NAME}> ;

    .

[] ja:loadClass "edu.rpi.tw.jena.query.fulltext.TextQuery" .

<#lucene_dataset_{NAME}> rdf:type text:TextDataset;
    text:index   <#indexLucene_{NAME}> ;
    text:dataset <#tdb_dataset_{NAME}> ;
.

<#tdb_dataset_{NAME}> rdf:type      tdb2:DatasetTDB2 ;
    tdb2:location "{FUSEKI_BASE}/databases{NAME}" ;
    tdb2:unionDefaultGraph true ;
    # Query timeout on this dataset (1s, 1000 milliseconds)
    ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "100000,600000" ] ;
    .

<#indexLucene_{NAME}> a text:TextIndexLucene ;
    text:directory <file://{FUSEKI_BASE}/databases{NAME}/lucene> ;
    text:entityMap <#entMap_{NAME}> ;
    .

<#entMap_{NAME}> a text:EntityMap ;
    text:entityField      "uri" ;
    text:defaultField     "text" ; ## Must be defined in the text:maps
    text:map (
        [ text:field "text" ; text:predicate rdfs:label ]
    )
    .
