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 Pascal Dimassimo <th...@hotmail.com> on 2009/03/12 16:04:28 UTC
Programmatic access to other handlers
Hi,
I've designed a "front" handler that will send request to other handlers and
return a aggregated response.
Inside this handler, I call other handlers like this (inside the method
handleRequestBody):
SolrCore core = req.getCore();
SolrRequestHandler mlt = core.getRequestHandler("/mlt");
ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
params.set("mlt.fl", "nFullText");
req.setParams(params);
mlt.handleRequest(req, rsp);
First question: is this the recommended way to call another handler?
Second question: how could I call a handler of another core?
--
View this message in context: http://www.nabble.com/Programmatic-access-to-other-handlers-tp22477731p22477731.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Programmatic access to other handlers
Posted by Chris Hostetter <ho...@fucit.org>.
: I implement the interface and it returns me the current core. But how is it
: different from doing request.getCore() from handleRequestBody()? And I don't
i think ryan missunderstood your goal .. that's just a way for you to get
access to your core prior to handling requests.
: see how this can give me access to other cores. I think that what I need is
: to get access to an instance of CoreContainer, so I can call getCore(name)
: and getAdminCore to manage the different cores. So I'm wondering if this is
: a good way to get that instance:
I'm not positive, but i think the code you listed will actaully
reconstruct new copies of all of the cores. the simplest way to get
access to the CoreContainer is via the CoreDescriptor...
yourCore.getCoreDescriptor().getCoreContainer().getCore("otherCoreName");
(note i've never actually done this, it's just waht i remember off the
top of my head from the past multicore design discussions ... the
class/method names may be slightly wrong)
-Hoss
Re: Programmatic access to other handlers
Posted by Pascal Dimassimo <th...@hotmail.com>.
Thanks ryantxu for your answer.
I implement the interface and it returns me the current core. But how is it
different from doing request.getCore() from handleRequestBody()? And I don't
see how this can give me access to other cores. I think that what I need is
to get access to an instance of CoreContainer, so I can call getCore(name)
and getAdminCore to manage the different cores. So I'm wondering if this is
a good way to get that instance:
CoreContainer.Initializer initializer = new
CoreContainer.Initializer();
CoreContainer cores = initializer.initialize();
ryantxu wrote:
>
> If you are doing this in a RequestHandler, implement SolrCoreAware and
> you will get a callback with the Core
>
> http://wiki.apache.org/solr/SolrPlugins#head-8b3ac1fc3584fe1e822924b98af23d72b02ab134
>
>
> On Mar 12, 2009, at 3:04 PM, Pascal Dimassimo wrote:
>
>>
>> I found this code to access other core from my custom requesthandler:
>>
>> CoreContainer.Initializer initializer = new
>> CoreContainer.Initializer();
>> CoreContainer cores = initializer.initialize();
>> SolrCore otherCore = cores.getCore("otherCore");
>>
>> It seems to work with some little testing. But is it a recommended
>> approach?
>>
>>
>> Pascal Dimassimo wrote:
>>>
>>> Hi,
>>>
>>> I've designed a "front" handler that will send request to other
>>> handlers
>>> and return a aggregated response.
>>>
>>> Inside this handler, I call other handlers like this (inside the
>>> method
>>> handleRequestBody):
>>>
>>> SolrCore core = req.getCore();
>>> SolrRequestHandler mlt = core.getRequestHandler("/mlt");
>>> ModifiableSolrParams params = new
>>> ModifiableSolrParams(req.getParams());
>>> params.set("mlt.fl", "nFullText");
>>> req.setParams(params);
>>> mlt.handleRequest(req, rsp);
>>>
>>> First question: is this the recommended way to call another handler?
>>> Second question: how could I call a handler of another core?
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Programmatic-access-to-other-handlers-tp22477731p22483357.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>
>
>
--
View this message in context: http://www.nabble.com/Programmatic-access-to-other-handlers-tp22477731p22486235.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Programmatic access to other handlers
Posted by Ryan McKinley <ry...@gmail.com>.
If you are doing this in a RequestHandler, implement SolrCoreAware and
you will get a callback with the Core
http://wiki.apache.org/solr/SolrPlugins#head-8b3ac1fc3584fe1e822924b98af23d72b02ab134
On Mar 12, 2009, at 3:04 PM, Pascal Dimassimo wrote:
>
> I found this code to access other core from my custom requesthandler:
>
> CoreContainer.Initializer initializer = new
> CoreContainer.Initializer();
> CoreContainer cores = initializer.initialize();
> SolrCore otherCore = cores.getCore("otherCore");
>
> It seems to work with some little testing. But is it a recommended
> approach?
>
>
> Pascal Dimassimo wrote:
>>
>> Hi,
>>
>> I've designed a "front" handler that will send request to other
>> handlers
>> and return a aggregated response.
>>
>> Inside this handler, I call other handlers like this (inside the
>> method
>> handleRequestBody):
>>
>> SolrCore core = req.getCore();
>> SolrRequestHandler mlt = core.getRequestHandler("/mlt");
>> ModifiableSolrParams params = new
>> ModifiableSolrParams(req.getParams());
>> params.set("mlt.fl", "nFullText");
>> req.setParams(params);
>> mlt.handleRequest(req, rsp);
>>
>> First question: is this the recommended way to call another handler?
>> Second question: how could I call a handler of another core?
>>
>
> --
> View this message in context: http://www.nabble.com/Programmatic-access-to-other-handlers-tp22477731p22483357.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
Re: Programmatic access to other handlers
Posted by Pascal Dimassimo <th...@hotmail.com>.
I found this code to access other core from my custom requesthandler:
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
CoreContainer cores = initializer.initialize();
SolrCore otherCore = cores.getCore("otherCore");
It seems to work with some little testing. But is it a recommended approach?
Pascal Dimassimo wrote:
>
> Hi,
>
> I've designed a "front" handler that will send request to other handlers
> and return a aggregated response.
>
> Inside this handler, I call other handlers like this (inside the method
> handleRequestBody):
>
> SolrCore core = req.getCore();
> SolrRequestHandler mlt = core.getRequestHandler("/mlt");
> ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
> params.set("mlt.fl", "nFullText");
> req.setParams(params);
> mlt.handleRequest(req, rsp);
>
> First question: is this the recommended way to call another handler?
> Second question: how could I call a handler of another core?
>
--
View this message in context: http://www.nabble.com/Programmatic-access-to-other-handlers-tp22477731p22483357.html
Sent from the Solr - User mailing list archive at Nabble.com.