On 21/08/13 21:45, Brad Moran wrote:
At this point I have a loaded TDB and text index, now I am trying to query
using java. First I tried creating a dataset directly from the TDB but
received
Dataset ds = TDBFactory.createDataset(DBDirectory); <--How I created Dataset
WARN o.apache.jena.query.text.TextQueryPF - Failed to find the text index
: tried context and as a text-enabled dataset
WARN o.apache.jena.query.text.TextQueryPF - No text index - no text search
performed
and returns an empty resultSet
I am trying to run this query:
QueryExecution qExec = QueryExecutionFactory.create(
"PREFIX text: <http://jena.apache.org/text#> PREFIX
mms: <http://rdf.cdisc.org/mms#> "
+ "SELECT * WHERE{?s text:query
(mms:dataElementName 'AEACN')}", ds);
ResultSet rs = qExec.execSelect();
So I figured the problem could be that I some how need to combine the TDB
and text index into the same dataset, I tried:
String DBDirectory = "tdb";
String indexDir = "luceneIndexes";
File file = new File(indexDir);
Directory dir = FSDirectory.open(file);
TextIndex index = new TextIndexLucene(dir, null);// need to add the
EntityDefinition?
Yes.
Dataset ds = TDBFactory.createDataset(DBDirectory);
Dataset dataset = TextDatasetFactory.create(ds, index);
then you will need to use 'dataset' not 'ds' to query.
This query does not run because of a nullPointerException.
stacktrace?
I am not sure if
this is the right way to go about this. If this is the right way to combine
a TDB and text index, is there an easy way to get the EntityDefinition from
the text index?
You can use the assembler file to get the dataset.
(see the text search documentation)
Else
EntityDefinition entDef = new EntityDefinition("uri", "text", RDFS.label) ;
and add the further declarations as in the assembler file.
The assembler means you can keep the configuation in one place
Andy