You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Erlend Hamnaberg <ng...@gmail.com> on 2008/10/02 23:18:28 UTC

Re: solr filesystem dependencies

Anyone?

On Thu, Sep 25, 2008 at 2:58 PM, Erlend Hamnaberg <ng...@gmail.com> wrote:

> Hi list.
> I am using the EmbeddedSolrServer to embed solr in my application, however
> I have run into a snag.
>
> The only filesystem dependency that I want is the index itself.
>
> The current implementation of the SolrResource seems to suggest that i need
> a filesystem dependency to keep my configuration in.
> I manged to work around this using the code below, but it feels kind of
> wrong.
>
>
>         SolrConfig config = new SolrConfig(null, null,
> getClass().getResourceAsStream(SOLR_CONFIG));
>         IndexSchema schema = new IndexSchema(config, null,
> getClass().getResourceAsStream(SOLR_SCHEMA));
>
>         CoreContainer coreContainer = new CoreContainer();
>
>         SolrCore core = new SolrCore("EMS", indexPath.getAbsolutePath(),
> config, schema, new CoreDescriptor(coreContainer, "EMS", SOLR_BASE));
>         coreContainer.register("EMS", core,  false);
>         SolrServer solrServer = new EmbeddedSolrServer(coreContainer,
> "EMS");
>
>
> Is there a recommended way of embedding the solr server?
>
>
> Thanks
>
> - Erlend
>

Re: solr filesystem dependencies

Posted by Erlend Hamnaberg <ng...@gmail.com>.
Right.

Thanks guys.

On Tue, Oct 7, 2008 at 6:01 AM, Chris Hostetter <ho...@fucit.org>wrote:

>
> : To instantiate the schema and core, you should not *need* any files on
> disk --
> : however, many of the plugins expect files like 'stopwords.txt'
> 'elevate.xml'
> : etc.  They use the ResourceLoader, so (in theory) you could hijack that
> to
> : send stuff from your .jar
>
> you shouldn't need to hijack anything -- getLines and all of the "open*"
> methods in SolrResourceLoader that the plugins use to open "files" are
> backed by openResource which will use ClassLoader.getResourceAsStream if
> it can't find them in the filesystem -- so if Solr Home is something like
> /dev/null there hould be no chance Solr even inadvertantly finding one of
> those files on disk -- it can always come from a jar.
>
>
> -Hoss
>
>

Re: solr filesystem dependencies

Posted by Chris Hostetter <ho...@fucit.org>.
: To instantiate the schema and core, you should not *need* any files on disk --
: however, many of the plugins expect files like 'stopwords.txt' 'elevate.xml'
: etc.  They use the ResourceLoader, so (in theory) you could hijack that to
: send stuff from your .jar

you shouldn't need to hijack anything -- getLines and all of the "open*" 
methods in SolrResourceLoader that the plugins use to open "files" are 
backed by openResource which will use ClassLoader.getResourceAsStream if 
it can't find them in the filesystem -- so if Solr Home is something like 
/dev/null there hould be no chance Solr even inadvertantly finding one of 
those files on disk -- it can always come from a jar.


-Hoss


Re: solr filesystem dependencies

Posted by Ryan McKinley <ry...@gmail.com>.
On Oct 6, 2008, at 5:58 PM, Chris Hostetter wrote:

>
> : > The only filesystem dependency that I want is the index itself.
>
> should we assume you're baking your solrconfig.xml and schema.xml
> directly into a jar?
>
> : > The current implementation of the SolrResource seems to suggest  
> that i need
> : > a filesystem dependency to keep my configuration in.
>
> I'm not sure what you mean by "SolrResource" ... there's no hard
> dependency on having any configs on disk that i know of (anymore)
>

To instantiate the schema and core, you should not *need* any files on  
disk -- however, many of the plugins expect files like 'stopwords.txt'  
'elevate.xml' etc.  They use the ResourceLoader, so (in theory) you  
could hijack that to send stuff from your .jar


> : > I manged to work around this using the code below, but it feels  
> kind of
> : > wrong.
>

If you get it working -- be happy and move on...  I don't think there  
is a clean way to do it off the shelf.

For solr 2.0 one of the biggest changes we need to make is to clearly  
separate configuration from implementation -- as is, Config/SolrConfig  
are smattered with settings, xpath and resource loading stuff.

We need to clearly separate the 'settings' from the means of loading  
the settings.

ryan

Re: solr filesystem dependencies

Posted by Chris Hostetter <ho...@fucit.org>.
: > The only filesystem dependency that I want is the index itself.

should we assume you're baking your solrconfig.xml and schema.xml  
directly into a jar?

: > The current implementation of the SolrResource seems to suggest that i need
: > a filesystem dependency to keep my configuration in.

I'm not sure what you mean by "SolrResource" ... there's no hard 
dependency on having any configs on disk that i know of (anymore)

: > I manged to work around this using the code below, but it feels kind of
: > wrong.

what feels wrong about it?  you need to provide a Stream to read the 
SolrConfig and IndexSchema from, and you're doing that.  it seems fine to 
me (but i'm not a big Embeeded guy so the experts might have more insight 
into a simpler way to do this...

: >         SolrConfig config = new SolrConfig(null, null,
: > getClass().getResourceAsStream(SOLR_CONFIG));
: >         IndexSchema schema = new IndexSchema(config, null,
: > getClass().getResourceAsStream(SOLR_SCHEMA));
: >
: >         CoreContainer coreContainer = new CoreContainer();
: >
: >         SolrCore core = new SolrCore("EMS", indexPath.getAbsolutePath(),
: > config, schema, new CoreDescriptor(coreContainer, "EMS", SOLR_BASE));
: >         coreContainer.register("EMS", core,  false);
: >         SolrServer solrServer = new EmbeddedSolrServer(coreContainer,
: > "EMS");


-Hoss