Do you have a complete, self-contained, minimal example?

        Andy

On 07/04/17 22:15, Dimov, Stefan wrote:
Ooops, correction:

        public static Dataset loadData() {
            Dataset ds = DatasetFactory.createTxnMem();
            Dataset indexDS = createIndex(ds);
            FileUtil.loadDataGraphs(indexDS, dataGraphs);
            return indexDS;
        }

        public static Dataset createIndex(Dataset ds) {
            Resource res = 
ResourceFactory.createProperty("http://ao.com/name/";);
            EntityDefinition entDef = new EntityDefinition("uri", "text", res) ;
            Directory dir =  new RAMDirectory();
            Dataset indexDataset = TextDatasetFactory.createLucene(ds, dir, 
entDef, null);
            return indexDataset;
        }


On 4/7/17, 2:12 PM, "Dimov, Stefan" <[email protected]> wrote:

    Thanks Andy,

    I’ve changed the code:

        public static Dataset loadData() {
            Dataset ds = DatasetFactory.createTxnMem();
            Dataset indexDS = createIndex(ds);
            FileUtil.loadDataGraphs(indexDS, dataGraphs);
            return ds;
        }

        public static Dataset createIndex(Dataset ds) {
            Resource res = 
ResourceFactory.createProperty("http://ao.com/name/";);
            EntityDefinition entDef = new EntityDefinition("uri", "text", res) ;
            Directory dir =  new RAMDirectory();
            Dataset indexDataset = TextDatasetFactory.createLucene(ds, dir, 
entDef, null);
            return indexDataset;
        }

    but after that, still text query returns empty result set.

    What am I missing?

    S.


    On 4/7/17, 1:48 PM, "Andy Seaborne" <[email protected]> wrote:

        >    Dataset ds = loadData();
                           ^^^^^^^^^^
        Not shown.

        >     …
        >     Resource res = 
ResourceFactory.createProperty("http://ao.com/name/";);
        >     EntityDefinition entDef = new EntityDefinition("uri", "text", 
res) ;
        >     Directory dir =  new RAMDirectory();
        >     Dataset indexDataset = TextDatasetFactory.createLucene(ds, dir, 
entDef, null);


        Stefan,

        You have to load the data through "indexDataset" - I guess you are
        loading it into a plain dataset in loadData.

        The Lucene index is built as data is added to the dataset, not when the
        dataset is wrapper later.

             Andy


        On 07/04/17 19:40, Dimov, Stefan wrote:
        > Thanks Rob,
        >
        > The problem is, for someone like me, who is new in Jena, it’s hard to 
follow the documentation – not enough examples and the explanations are kind of 
ambiguous (again – from my point of view).
        >
        > I was hoping on comment and snippet, specifically about my example.
        >
        >
        > S.
        >
        >
        >
        > On 4/7/17, 2:25 AM, "Rob Vesse" <[email protected]> wrote:
        >
        >     What these lines are doing is creating a blank index, in 
particular the last line simply associates a pre-existing index with a dataset 
i.e. It doesn’t actually cause indexing to happen, typically you would first build 
a persistent Lucene index using the command line tool
        >
        >     
http://jena.apache.org/documentation/query/text-query.html#building-a-text-index
        >
        >      if you want to explicitly built the index from code your best 
bet is to refer to the code for the commandline tool:
        >
        >     
https://github.com/apache/jena/blob/master/jena-text/src/main/java/jena/textindexer.java
        >
        >     Rob
        >
        >     On 07/04/2017 04:07, "Dimov, Stefan" <[email protected]> wrote:
        >
        >         Resource res = 
ResourceFactory.createProperty("http://ao.com/name/";);
        >         EntityDefinition entDef = new EntityDefinition("uri", "text", 
res) ;
        >         Directory dir =  new RAMDirectory();
        >         Dataset indexDataset = TextDatasetFactory.createLucene(ds, 
dir, entDef, null);
        >
        >
        >
        >
        >
        >




Reply via email to