Phil,
How do you know it does not work? The code (groovy?) does not read the
index. Could you provide a complete example (I don't have groovy
installed ATM).
(which version are you using?)
Andy
On 10/10/14 01:50, Phillip Rhodes wrote:
Jena crew:
I have Jena-Text pretty much working for what I want to do, but with
one caveat... it only seems to work with the Lucene RamDirectory. If
I use a persistent dir, I don't find any documents being written to
the Lucene index. Any help or suggestions are greatly appreciated.
Code sample follows:
---CODE---
package org.fogbeam.example.jenatext
import org.apache.jena.query.text.EntityDefinition
import org.apache.jena.query.text.TextDatasetFactory
import org.apache.jena.query.text.TextQuery
import org.apache.lucene.store.Directory
import org.apache.lucene.store.FSDirectory
import com.hp.hpl.jena.query.Dataset
import com.hp.hpl.jena.query.ReadWrite
import com.hp.hpl.jena.rdf.model.Model
import com.hp.hpl.jena.rdf.model.Resource
import com.hp.hpl.jena.rdf.model.Statement
import com.hp.hpl.jena.tdb.TDBFactory
import com.hp.hpl.jena.vocabulary.RDFS
class JenaTextMain6Write
{
static main(args)
{
TextQuery.init();
EntityDefinition entDef = new EntityDefinition("uri", "text",
RDFS.label.asNode()) ;
// Lucene, in memory.
Directory dir = FSDirectory.open( new File( "jenastore/index" ) );
// Join together into a dataset
Dataset tdbDataset = TDBFactory.createDataset("jenastore/triples");
Dataset ds = TextDatasetFactory.createLucene(tdbDataset, dir, entDef);
try
{
ds.begin(ReadWrite.WRITE);
Model m = ds.getDefaultModel();
Resource rSubject = m.createResource(
"http://ontology.fogbeam.com/example/TestResource1" );
Resource rSubject2 = m.createResource(
"http://ontology.fogbeam.com/example/TestResource2" );
Statement s = m.createStatement(rSubject, RDFS.label,
"This is a Test Resource" );
m.add( s );
Statement s2 = m.createStatement(rSubject2, RDFS.label,
"Bratwurst Test" );
m.add( s2 );
ds.commit();
dir.close();
}
catch( Exception e )
{
e.printStackTrace();
ds.abort();
}
finally
{
if( ds != null )
{
ds.end();
}
}
println "done";
}
}
--- END CODE---
Phil
---
This message optimized for indexing by NSA PRISM