Hi Claudio,
You need to add the model from the original dataset (ds1) to the model of
the indexed dataset (ds). So something like:
ds.begin(ReadWrite.WRITE) ;
try {
Model m = ds.getDefaultModel() ;
m.add(ds1.getDefaultModel())
ds.commit() ;
} finally { ds.end() ; }
This needs to be done before you attempt to query the indexed dataset.
On Mon, Jul 7, 2014 at 6:40 AM, Claudio Pomo <[email protected]> wrote:
> Following the example in this url
>
> https://svn.apache.org/repos/asf/jena/trunk/jena-text/src/main/java/examples/JenaTextExample1.java
> and I've wrote this code:
>
> public Boolean queryText() {
>
>
> try {
> TextQuery.init();
> Dataset ds1 = TDBFactory.createDataset(FUSEKI_HOME);
> ds1.begin(ReadWrite.READ);
> EntityDefinition entDef = new EntityDefinition("uri", "text",
> RDFS.label.asNode()) ;
> Directory dir = new RAMDirectory();
> Dataset ds = TextDatasetFactory.createLucene(ds1, dir, entDef) ;
> ds1.commit();
> ds1.end();
> String pre = StrUtils.strjoinNL
> ( "PREFIX text: <http://jena.apache.org/text#>"
> , "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>") ;
>
> String qs = StrUtils.strjoinNL
> ( "SELECT * "
> , " { ?s text:query (rdfs:label 'pietro') ;"
> , " rdfs:label ?label"
> , " }") ;
> ds.begin(ReadWrite.READ);
> Query q = QueryFactory.create(pre+"\n"+qs) ;
> QueryExecution qexec = QueryExecutionFactory.create(q , ds) ;
> QueryExecUtils.executeQuery(q, qexec) ;
> ds.end();
>
> }catch (Exception e){
> e.printStackTrace();
> }
>
>
> return null;
> }
>
> But I've this message on console:
> 2014-07-07 12:07:49,771 WARN [main] Log - Failed to find the text index :
> tried context and as a text-enabled dataset
> 2014-07-07 12:07:49,776 WARN [main] Log - No text index - no text search
> performed
> I don't understand what is the problem
> -------------------------
> Claudio Pomo
> +39 3201176508
> Stasbranger Srl
>
> I hope in Meraki <http://meraki.com>
>
--
Cheers,
Willie