Hi,
I used these commands for indexing the data.
Loading data to tdb :
java -cp %FUSEKI_HOME%/fuseki-server.jar tdb.tdbloader
--tdb="Path of assembler file" "path of file to be indexed"
Indexing Predicates:
java -cp %FUSEKI_HOME%/fuseki-server.jar jena.textindexer --desc="path of
assembler file"
After Indexing use this code:
TextQuery.init();
Dataset dataset = null;
Dataset tdbDataset = TDBFactory.createDataset(tdbFilePath);
try {
EntityDefinition entDef = new EntityDefinition("uri", "text",
RDFS.label);
Directory dir = FSDirectory.open(new File(luceneFilePath));
dataset = TextDatasetFactory.createLucene(tdbDataset, dir,
entDef);
dataset .begin(ReadWrite.READ);
> Model model = dataset .getDefaultModel();
> Query q = QueryFactory.create(pre + "\n"
> + qs);
>
// here qs is the query String (Sparql Query)
QueryExecution qexec =QueryExecutionFactory.create(q, ds);
> QueryExecUtils.executeQuery(q,
> qexec);
>
> dataset .commit();
> dataset .end();
} catch (Exception e) {
System.out.println(e.toString());
}
Thanks
On Thu, May 15, 2014 at 7:00 PM, Andy Seaborne <[email protected]> wrote:
> On 08/05/14 07:21, Karen Menz wrote:
>
>> Hi,
>> I'm trying to get Lucene working with TDB,
>> but no luck so far.
>> I already
>> have a TDB dataset saved in "tdb_directory" folder, with the following
>> platform:
>> Jena-2.11.1
>> Lucene-4.8.0 (Apache)
>> Java-1.7.0,
>> 64-Bit
>>
>> And I have
>> the following code:
>> Dataset ds1 = TDBFactory.createDataset(tdb_directory);
>> EntityDefinition entDef = new
>> EntityDefinition("uri", "text", RDFS.label.asNode());
>> File indexDir = new File(index_directory);
>> try{
>> dir
>> = FSDirectory.open(indexDir);
>> } catch(IOException e) {
>> e.printStackTrace();
>> }
>> Dataset ds = TextDatasetFactory.createLucene(ds1,
>> dir, entDef);
>>
>> Then, when I execute the query as
>> following:
>>
>> ds.begin(ReadWrite.READ);
>> Model model = ds.getDefaultModel();
>> Query q = QueryFactory.create(pre + "\n"
>> + qs);
>>
>
> What's 'qs'?
>
> QueryExecution qexec =
>> QueryExecutionFactory.create(q, ds);
>> QueryExecUtils.executeQuery(q,
>> qexec);
>>
>> ds.commit();
>> ds.end();
>>
>> I get an empty table
>> -------------
>> | s | label |
>> =============
>>
>> and in the index_directory, only 3
>> file were created; segments.gen, segments_1, and write.lock, with sizes
>> 1kb,
>> 1kb, 0kb, respectively.
>>
>> I'm not sure what I'm missing here,
>> and really appreciate any help.
>>
>
> looks like the data isn't indexed. It does not happen automatically just
> by atatching and index to an existing, preloaded dataset.
>
> Either have the index attached to the dataset when you loaded the data or
> build the dataset in two steps:
>
> http://jena.apache.org/documentation/query/text-
> query.html#building-a-text-index
>
> There is a textindexer to run from the command line for indexing existing
> data.
>
> Andy
>
>
>
>
>
>> Thanks in advance.
>>
>> Karen
>>
>>
>