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 Jason Rutherglen <ja...@gmail.com> on 2009/09/30 00:49:44 UTC

Get access to CoreContainer

Howdy,

I was wondering what the best way is to access the current
instance of CoreContainer? It seems like the only way to do this
is to extend CoreAdminHandler. I'd prefer a way via a way to
access CoreContainer from SolrCore or RequestHandlerBase.

The use case is, I want to implement a SearchHandler that by
default, searches all of the local cores by automatically
inserting a shards param of the form
"localhost:8080/solr/core0,localhost:8080/solr/core1" into the
request. I'll be dynamically creating and unloading cores and so
do not want to edit solrconfig each time a core changes.

Thanks!

Re: Get access to CoreContainer

Posted by Jason Rutherglen <ja...@gmail.com>.
I'll just allow the user to pass in the port via a param for now.

Thx!

On Tue, Sep 29, 2009 at 4:13 PM, Mark Miller <ma...@gmail.com> wrote:
> Unfortunately, because they don't want you counting on access to the
> servlet request due to embedded Solr and what not, to get that type of
> info you have to override and use your own SolrDispatchFilter:
>
>  protected void execute( HttpServletRequest req, SolrRequestHandler
> handler, SolrQueryRequest sreq, SolrQueryResponse rsp) {
>
>    // a custom filter could add more stuff to the request before
> passing it on.
>    // for example: sreq.getContext().put( "HttpServletRequest", req );
>
>
> Jason Rutherglen wrote:
>> Yah, I just found it, and was going to reply to my own message with
>> that exactly!
>>
>> My next question is how to get the port the request was on?
>>
>> On Tue, Sep 29, 2009 at 4:01 PM, Mark Miller <ma...@gmail.com> wrote:
>>
>>> Jason Rutherglen wrote:
>>>
>>>> Howdy,
>>>>
>>>> I was wondering what the best way is to access the current
>>>> instance of CoreContainer? It seems like the only way to do this
>>>> is to extend CoreAdminHandler. I'd prefer a way via a way to
>>>> access CoreContainer from SolrCore or RequestHandlerBase.
>>>>
>>>> The use case is, I want to implement a SearchHandler that by
>>>> default, searches all of the local cores by automatically
>>>> inserting a shards param of the form
>>>> "localhost:8080/solr/core0,localhost:8080/solr/core1" into the
>>>> request. I'll be dynamically creating and unloading cores and so
>>>> do not want to edit solrconfig each time a core changes.
>>>>
>>>> Thanks!
>>>>
>>>>
>>> SolrCore.getCoreDescriptor().getCoreContainer()
>>>
>>> --
>>> - Mark
>>>
>>> http://www.lucidimagination.com
>>>
>>>
>>>
>>>
>>>
>
>
> --
> - Mark
>
> http://www.lucidimagination.com
>
>
>
>

Re: Get access to CoreContainer

Posted by Mark Miller <ma...@gmail.com>.
Unfortunately, because they don't want you counting on access to the
servlet request due to embedded Solr and what not, to get that type of
info you have to override and use your own SolrDispatchFilter:

  protected void execute( HttpServletRequest req, SolrRequestHandler
handler, SolrQueryRequest sreq, SolrQueryResponse rsp) {

    // a custom filter could add more stuff to the request before
passing it on.
    // for example: sreq.getContext().put( "HttpServletRequest", req );


Jason Rutherglen wrote:
> Yah, I just found it, and was going to reply to my own message with
> that exactly!
>
> My next question is how to get the port the request was on?
>
> On Tue, Sep 29, 2009 at 4:01 PM, Mark Miller <ma...@gmail.com> wrote:
>   
>> Jason Rutherglen wrote:
>>     
>>> Howdy,
>>>
>>> I was wondering what the best way is to access the current
>>> instance of CoreContainer? It seems like the only way to do this
>>> is to extend CoreAdminHandler. I'd prefer a way via a way to
>>> access CoreContainer from SolrCore or RequestHandlerBase.
>>>
>>> The use case is, I want to implement a SearchHandler that by
>>> default, searches all of the local cores by automatically
>>> inserting a shards param of the form
>>> "localhost:8080/solr/core0,localhost:8080/solr/core1" into the
>>> request. I'll be dynamically creating and unloading cores and so
>>> do not want to edit solrconfig each time a core changes.
>>>
>>> Thanks!
>>>
>>>       
>> SolrCore.getCoreDescriptor().getCoreContainer()
>>
>> --
>> - Mark
>>
>> http://www.lucidimagination.com
>>
>>
>>
>>
>>     


-- 
- Mark

http://www.lucidimagination.com




Re: Get access to CoreContainer

Posted by Jason Rutherglen <ja...@gmail.com>.
Yah, I just found it, and was going to reply to my own message with
that exactly!

My next question is how to get the port the request was on?

On Tue, Sep 29, 2009 at 4:01 PM, Mark Miller <ma...@gmail.com> wrote:
> Jason Rutherglen wrote:
>> Howdy,
>>
>> I was wondering what the best way is to access the current
>> instance of CoreContainer? It seems like the only way to do this
>> is to extend CoreAdminHandler. I'd prefer a way via a way to
>> access CoreContainer from SolrCore or RequestHandlerBase.
>>
>> The use case is, I want to implement a SearchHandler that by
>> default, searches all of the local cores by automatically
>> inserting a shards param of the form
>> "localhost:8080/solr/core0,localhost:8080/solr/core1" into the
>> request. I'll be dynamically creating and unloading cores and so
>> do not want to edit solrconfig each time a core changes.
>>
>> Thanks!
>>
> SolrCore.getCoreDescriptor().getCoreContainer()
>
> --
> - Mark
>
> http://www.lucidimagination.com
>
>
>
>

Re: Get access to CoreContainer

Posted by Mark Miller <ma...@gmail.com>.
Jason Rutherglen wrote:
> Howdy,
>
> I was wondering what the best way is to access the current
> instance of CoreContainer? It seems like the only way to do this
> is to extend CoreAdminHandler. I'd prefer a way via a way to
> access CoreContainer from SolrCore or RequestHandlerBase.
>
> The use case is, I want to implement a SearchHandler that by
> default, searches all of the local cores by automatically
> inserting a shards param of the form
> "localhost:8080/solr/core0,localhost:8080/solr/core1" into the
> request. I'll be dynamically creating and unloading cores and so
> do not want to edit solrconfig each time a core changes.
>
> Thanks!
>   
SolrCore.getCoreDescriptor().getCoreContainer()

-- 
- Mark

http://www.lucidimagination.com