On 01/04/14 17:29, Harkishan Singh wrote:
Hi,
I have loaded large N-Triple data into tdb by using tdbloader.
This is a command that I have used :
C:\apache-jena-2.11.1\bat>tdbloader --loc tdblocation xyz.nt

This does not index the text.




After that I have written java code for text based search.

public static void main(String[] args) {
         Dataset ds = null;
         String directory = "TDB";
         Dataset ds1 = TDBFactory.createDataset(directory);
         try {
             EntityDefinition entDef = new EntityDefinition("uri",
"property", RDFS.label);
             Directory dir = FSDirectory.open(new File("LUCENE"));

You need to build the index - that only connects to it.

http://jena.apache.org/documentation/query/text-query.html#building-a-text-index

jena.textindexer is a program to index existing data - use that after tdbloader.

If you data isn't too large, you can also create the TextDataset, then load the data by reading in the RDF and both the DB and the Lucene index will be built. You don't get the efficiency of tdbloader through.

tdbloader manipulates the on-disk indexes - it knows the internals of TDB.

        Andy


             ds = TextDatasetFactory.createLucene(ds1, dir, entDef);

             String queryString = "PREFIX rdf: <
http://www.w3.org/1999/02/22-rdf-
        syntax-ns#> \n"
                 + " PREFIX text: <http://jena.apache.org/text#> \n"
                 + " Select * where  {?s text:query \"xyz\" . \n"
                 + " }";

             ds.begin(ReadWrite.READ);

             Query q = QueryFactory.create(queryString);
             QueryExecution qexec = QueryExecutionFactory.create(q, ds);
             QueryExecUtils.executeQuery(q, qexec);
             ds.end();

         } catch (Exception e) {
             System.out.println(e.toString());
         }

     }


The above code doesn't give any result.
And after the execution of this line ( ds =
TextDatasetFactory.createLucene(ds1, dir, entDef);) I thought that it will
create the index, but I can't see anything in LUCENE folder.

Therefore I think that it doesn't have the index data therefore text:query
is not working.

If I replace text:query with ?p , it shows some result.
But I want to do text based search on the dataset created from TDB.

Does any one know how to make it work??
Any suggestions?


Reply via email to