You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Dimov, Stefan" <st...@sap.com> on 2017/10/18 01:54:51 UTC

Create Lucene index from existing TDB

Hello,

I have an existing (persisted) TDB and I’m starting Fuseki like this:

            Location location = Location.create("tdb");
            ds = TDBFactory.createDataset(location);
            FusekiServer fs = FusekiServer.create()
                    .add("/ds", ds)
                    .build();
            fs.start();

I want to create a (persisted) index from it for specific subject like this:

        EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
        Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
        entDef.setPrimaryPredicate(res);
        Path path = Paths.get("lucene_index");
        Directory dir = FSDirectory.open(path);
        ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);

So, the code looks like this:

        Location location = Location.create("tdb");
        ds = TDBFactory.createDataset(location);

        EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
        Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
        entDef.setPrimaryPredicate(res);
        Path path = Paths.get("lucene_index");
        Directory dir = FSDirectory.open(path);
        ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);

        FusekiServer fs = FusekiServer.create()
                    .add("/ds", ds)
                    .build();
         fs.start();

and the dataset is getting loaded, but no index is getting created.

What am I doing wrong?

S.



Re: Create Lucene index from existing TDB

Posted by Rob Vesse <rv...@dotnetrdf.org>.
Sorry I can’t

 It is not a component of the software I use myself, I’m just aware that the specific issue you encounter exists. Yes, the documentation is probably lacking in this regard. Hopefully others who do work with this component may be able to provide some help

Rob

On 18/10/2017 21:07, "Dimov, Stefan" <st...@sap.com> wrote:

    Thanks Rob,
    
    Can you, please, give me more specific example, suited for my particular case? I find the documentation hard to follow.
    
    Regards,
    Stefan
    
    
    
    On 10/18/17, 2:11 AM, "Rob Vesse" <rv...@dotnetrdf.org> wrote:
    
        Your current code simply creates a Lucene backed index with your desired configuration but it doesn’t actually populate the index.
        
        You have to explicitly populate the index first either with the command line tool or by manually building the index from code similar to how the command line tool does it:
        
        https://github.com/apache/jena/blob/master/jena-text/src/main/java/jena/textindexer.java#L106
        
        Rob
        
        On 18/10/2017 02:54, "Dimov, Stefan" <st...@sap.com> wrote:
        
            Hello,
            
            I have an existing (persisted) TDB and I’m starting Fuseki like this:
            
                        Location location = Location.create("tdb");
                        ds = TDBFactory.createDataset(location);
                        FusekiServer fs = FusekiServer.create()
                                .add("/ds", ds)
                                .build();
                        fs.start();
            
            I want to create a (persisted) index from it for specific subject like this:
            
                    EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
                    Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
                    entDef.setPrimaryPredicate(res);
                    Path path = Paths.get("lucene_index");
                    Directory dir = FSDirectory.open(path);
                    ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
            
            So, the code looks like this:
            
                    Location location = Location.create("tdb");
                    ds = TDBFactory.createDataset(location);
            
                    EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
                    Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
                    entDef.setPrimaryPredicate(res);
                    Path path = Paths.get("lucene_index");
                    Directory dir = FSDirectory.open(path);
                    ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
            
                    FusekiServer fs = FusekiServer.create()
                                .add("/ds", ds)
                                .build();
                     fs.start();
            
            and the dataset is getting loaded, but no index is getting created.
            
            What am I doing wrong?
            
            S.
            
            
            
        
        
        
        
        
    
    





Re: Create Lucene index from existing TDB

Posted by "Dimov, Stefan" <st...@sap.com>.
Thanks Rob,

Can you, please, give me more specific example, suited for my particular case? I find the documentation hard to follow.

Regards,
Stefan



On 10/18/17, 2:11 AM, "Rob Vesse" <rv...@dotnetrdf.org> wrote:

    Your current code simply creates a Lucene backed index with your desired configuration but it doesn’t actually populate the index.
    
    You have to explicitly populate the index first either with the command line tool or by manually building the index from code similar to how the command line tool does it:
    
    https://github.com/apache/jena/blob/master/jena-text/src/main/java/jena/textindexer.java#L106
    
    Rob
    
    On 18/10/2017 02:54, "Dimov, Stefan" <st...@sap.com> wrote:
    
        Hello,
        
        I have an existing (persisted) TDB and I’m starting Fuseki like this:
        
                    Location location = Location.create("tdb");
                    ds = TDBFactory.createDataset(location);
                    FusekiServer fs = FusekiServer.create()
                            .add("/ds", ds)
                            .build();
                    fs.start();
        
        I want to create a (persisted) index from it for specific subject like this:
        
                EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
                Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
                entDef.setPrimaryPredicate(res);
                Path path = Paths.get("lucene_index");
                Directory dir = FSDirectory.open(path);
                ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
        
        So, the code looks like this:
        
                Location location = Location.create("tdb");
                ds = TDBFactory.createDataset(location);
        
                EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
                Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
                entDef.setPrimaryPredicate(res);
                Path path = Paths.get("lucene_index");
                Directory dir = FSDirectory.open(path);
                ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
        
                FusekiServer fs = FusekiServer.create()
                            .add("/ds", ds)
                            .build();
                 fs.start();
        
        and the dataset is getting loaded, but no index is getting created.
        
        What am I doing wrong?
        
        S.
        
        
        
    
    
    
    
    


Re: Create Lucene index from existing TDB

Posted by Rob Vesse <rv...@dotnetrdf.org>.
Your current code simply creates a Lucene backed index with your desired configuration but it doesn’t actually populate the index.

You have to explicitly populate the index first either with the command line tool or by manually building the index from code similar to how the command line tool does it:

https://github.com/apache/jena/blob/master/jena-text/src/main/java/jena/textindexer.java#L106

Rob

On 18/10/2017 02:54, "Dimov, Stefan" <st...@sap.com> wrote:

    Hello,
    
    I have an existing (persisted) TDB and I’m starting Fuseki like this:
    
                Location location = Location.create("tdb");
                ds = TDBFactory.createDataset(location);
                FusekiServer fs = FusekiServer.create()
                        .add("/ds", ds)
                        .build();
                fs.start();
    
    I want to create a (persisted) index from it for specific subject like this:
    
            EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
            Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
            entDef.setPrimaryPredicate(res);
            Path path = Paths.get("lucene_index");
            Directory dir = FSDirectory.open(path);
            ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
    
    So, the code looks like this:
    
            Location location = Location.create("tdb");
            ds = TDBFactory.createDataset(location);
    
            EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
            Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
            entDef.setPrimaryPredicate(res);
            Path path = Paths.get("lucene_index");
            Directory dir = FSDirectory.open(path);
            ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
    
            FusekiServer fs = FusekiServer.create()
                        .add("/ds", ds)
                        .build();
             fs.start();
    
    and the dataset is getting loaded, but no index is getting created.
    
    What am I doing wrong?
    
    S.
    
    
    





Re: Create Lucene index from existing TDB

Posted by "Dimov, Stefan" <st...@sap.com>.
Thanks, Andy!

S.

On 10/19/17, 10:54 AM, "Andy Seaborne" <an...@apache.org> wrote:

    (sorry for the brief reply ... travelling)
    
    On 17/10/17 21:54, Dimov, Stefan wrote:
    > Hello,
    > 
    > I have an existing (persisted) TDB and I’m starting Fuseki like this:
    > 
    >              Location location = Location.create("tdb");
    >              ds = TDBFactory.createDataset(location);
    
    See TextDatasetFactory.create(Dataset base, TextIndex textIndex)
    
    and register that dataset built around the TDB one.
    
         Andy
    
    
    >              FusekiServer fs = FusekiServer.create()
    >                      .add("/ds", ds)
    >                      .build();
    >              fs.start();
    > 
    > I want to create a (persisted) index from it for specific subject like this:
    > 
    >          EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
    >          Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
    >          entDef.setPrimaryPredicate(res);
    >          Path path = Paths.get("lucene_index");
    >          Directory dir = FSDirectory.open(path);
    >          ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
    > 
    > So, the code looks like this:
    > 
    >          Location location = Location.create("tdb");
    >          ds = TDBFactory.createDataset(location);
    > 
    >          EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
    >          Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
    >          entDef.setPrimaryPredicate(res);
    >          Path path = Paths.get("lucene_index");
    >          Directory dir = FSDirectory.open(path);
    >          ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
    > 
    >          FusekiServer fs = FusekiServer.create()
    >                      .add("/ds", ds)
    >                      .build();
    >           fs.start();
    > 
    > and the dataset is getting loaded, but no index is getting created.
    > 
    > What am I doing wrong?
    > 
    > S.
    > 
    > 
    


Re: Create Lucene index from existing TDB

Posted by Andy Seaborne <an...@apache.org>.
(sorry for the brief reply ... travelling)

On 17/10/17 21:54, Dimov, Stefan wrote:
> Hello,
> 
> I have an existing (persisted) TDB and I’m starting Fuseki like this:
> 
>              Location location = Location.create("tdb");
>              ds = TDBFactory.createDataset(location);

See TextDatasetFactory.create(Dataset base, TextIndex textIndex)

and register that dataset built around the TDB one.

     Andy


>              FusekiServer fs = FusekiServer.create()
>                      .add("/ds", ds)
>                      .build();
>              fs.start();
> 
> I want to create a (persisted) index from it for specific subject like this:
> 
>          EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
>          Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
>          entDef.setPrimaryPredicate(res);
>          Path path = Paths.get("lucene_index");
>          Directory dir = FSDirectory.open(path);
>          ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
> 
> So, the code looks like this:
> 
>          Location location = Location.create("tdb");
>          ds = TDBFactory.createDataset(location);
> 
>          EntityDefinition entDef = new EntityDefinition("uri", "text", "graph") ;
>          Resource res = ResourceFactory.createProperty(“http:/ao.com/name”);
>          entDef.setPrimaryPredicate(res);
>          Path path = Paths.get("lucene_index");
>          Directory dir = FSDirectory.open(path);
>          ds = TextDatasetFactory.createLucene(ds, dir, entDef, null);
> 
>          FusekiServer fs = FusekiServer.create()
>                      .add("/ds", ds)
>                      .build();
>           fs.start();
> 
> and the dataset is getting loaded, but no index is getting created.
> 
> What am I doing wrong?
> 
> S.
> 
>