No need to use tdb anymore. By using the configuration below and calling
jena.textIndexer, I was able to index data successfully:

@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 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 spatial: <http://jena.apache.org/spatial#> .

[] a fuseki:Server ;
    fuseki:services (
        :categorydb
    )
    .

:categorydb a fuseki:Service ;
    fuseki:name                         "elo7_category" ;
    fuseki:serviceQuery                 "sparql" ;
    fuseki:serviceQuery                 "query" ;
    fuseki:serviceUpdate                "update" ; # SPARQL query service –
/memory/update
    fuseki:serviceUpload                "upload" ; # Non-SPARQL upload
service
    fuseki:serviceReadWriteGraphStore   "data" ;
    fuseki:serviceReadGraphStore        "get" ; # Graph store protocol
(read only) –/memory/get
    fuseki:dataset                      :text_dataset ;
    .

:text_dataset rdf:type text:TextDataset ;
    text:dataset :memory_dataset ;
    text:index :lucene-text_index ;
    .

:memory_dataset rdf:type ja:MemoryDataset ;
    ja:data <file:////opt/host/rdf.owl> ;
    .

:lucene-text_index a text:TextIndexLucene ;
    text:directory "mem" ;
    text:entityMap :entity_map ;
    .

:entity_map a text:EntityMap ;
    text:entityField "uri" ;
    text:defaultField "text" ;
    text:map (
        [ text:field "text" ; text:predicate rdfs:label ]
    )
    .

Thanks for helping!

Em sex., 28 de ago. de 2020 às 12:08, Rodrigo Vedovato <
[email protected]> escreveu:

> Thanks for the Lucene index tip!
>
> I was able to make it work by replacing MemoryModel with a DatasetTDB and
> calling "java -cp ./fuseki-server.jar tdb.tdbloader --tdb=$DB_CONFIG
> $DB_FILE" and "java -cp ./fuseki-server.jar jena.textindexer
> --desc=$DB_CONFIG" prior to starting the server.
>
> Quick question:  I know you can use tdb:location "--mem--" to create an
> in-memory tdb dataset, but is this advised for production environments? I
> wonder if querying an in-memory dataset will be faster than storing it on
> the disk. Please consider this is a read-only database and I'll be hosting
> it on Kubernetes, so if my application fails for some reason, it is ready
> to recover the file contents.
>
> Rodrigo
>
>
> Em sex., 28 de ago. de 2020 às 11:41, Andy Seaborne <[email protected]>
> escreveu:
>
>>  > :memory_dataset rdf:type ja:RDFDataset ;
>>  >      ja:defaultGraph
>>  >          [
>>  >              a ja:MemoryModel ;
>>  >              ja:content [ ja:externalContent
>>  > <file:////path/to/file/tests.owl> ] ;
>>          ^^^^
>>  >          ] ;
>>
>> That loads the RDF data into the memory model directly, bypassing the
>> text index. To set the index, you'll need to load somehow with the same
>> data offline or start an empty server then push the data into it.
>>
>> BTW1  text:directory "mem"
>> wil create an in-mmeory Lucense index.)
>>
>> BTW2 There is an in-memory dataset implementation
>>
>> :memory_dataset rdf:type ja:MemoryDataset;
>>     ja:data "data.trig";
>> .
>>
>>      Andy
>>
>> On 27/08/2020 18:00, Rodrigo Vedovato wrote:
>> > Hi there,
>> >
>> > I'm setting up a Fuseki server using the following configuration:
>> >
>> > @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 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 spatial: <http://jena.apache.org/spatial#> .
>> >
>> > [] a fuseki:Server ;
>> >      fuseki:services (
>> >          :categorydb
>> >      )
>> >      .
>> >
>> > :categorydb a fuseki:Service ;
>> >      fuseki:name                         "db" ;
>> >      fuseki:serviceQuery                 "sparql" ;
>> >      fuseki:serviceQuery                 "query" ;
>> >      fuseki:serviceUpdate                "update" ; # SPARQL query
>> service –
>> > /memory/update
>> >      fuseki:serviceUpload                "upload" ; # Non-SPARQL upload
>> > service
>> >      fuseki:serviceReadWriteGraphStore   "data" ;
>> >      fuseki:serviceReadGraphStore        "get" ; # Graph store protocol
>> > (read only) –/memory/get
>> >      fuseki:dataset                      :text_dataset ;
>> >      .
>> >
>> > :text_dataset rdf:type text:TextDataset ;
>> >      text:dataset :memory_dataset ;
>> >      text:index :lucene-text_index ;
>> >      .
>> >
>> > :memory_dataset rdf:type ja:RDFDataset ;
>> >      ja:defaultGraph
>> >          [
>> >              a ja:MemoryModel ;
>> >              ja:content [ ja:externalContent
>> > <file:////path/to/file/tests.owl> ] ;
>> >          ] ;
>> >      .
>> >
>> > :lucene-text_index a text:TextIndexLucene ;
>> >      text:directory <file:///opt/fuseki/index/ix> ;
>> >      text:entityMap :entity_map ;
>> >      .
>> >
>> > :entity_map a text:EntityMap ;
>> >      text:entityField "uri" ;
>> >      text:defaultField "text" ;
>> >      text:map (
>> >          [ text:field "text" ; text:predicate rdfs:label ]
>> >      )
>> >      .
>> >
>> > Server startup works fine, and the data from my owl file is loaded
>> > successfully. I can check it by executing:
>> >
>> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> > PREFIX ns:<
>> >
>> http://www.semanticweb.org/rodrigo/ontologies/2020/7/untitled-ontology-7#
>> >
>> > PREFIX owl:<http://www.w3.org/2002/07/owl#NamedIndividual>
>> > PREFIX owls: <http://www.daml.org/services/owl-s/1.2/Service.owl#>
>> > PREFIX text: <http://jena.apache.org/text#>
>> >
>> > SELECT ?brand
>> > WHERE {
>> >      ?brand rdfs:subClassOf ns:mobile-phones .
>> > }
>> >
>> > However, I get no result when I execute a text query:
>> >
>> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> > PREFIX ns:<
>> >
>> http://www.semanticweb.org/rodrigo/ontologies/2020/7/untitled-ontology-7#
>> >
>> > PREFIX owl:<http://www.w3.org/2002/07/owl#NamedIndividual>
>> > PREFIX owls: <http://www.daml.org/services/owl-s/1.2/Service.owl#>
>> > PREFIX text: <http://jena.apache.org/text#>
>> >
>> > SELECT ?s { ?s text:query ('samsung') }
>> >
>> > This behavior, according to this thread
>> > <https://jena.markmail.org/thread/grni3o6ch5tfak4j> and JENA-956
>> > <https://issues.apache.org/jira/browse/JENA-956>, has been fixed in
>> 3.0.0,
>> > but I can't get this to work as expected. Am I doing something wrong?
>> >
>> > $ ./fuseki-server --version
>> > Jena:       VERSION: 3.16.0
>> > Jena:       BUILD_DATE: 2020-07-09T16:13:45+0000
>> > TDB:        VERSION: 3.16.0
>> > TDB:        BUILD_DATE: 2020-07-09T16:13:45+0000
>> > Fuseki:     VERSION: 3.16.0
>> > Fuseki:     BUILD_DATE: 2020-07-09T16:13:45+0000
>> >
>> > owl file: https://www.dropbox.com/s/1r1j7alstvhakv0/tests.owl?dl=0
>> >
>> > Regards,
>> > Rodrigo Vedovato
>> >
>>
>

Reply via email to