Redirecting SolrQueryRequests to another core with Handler

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Redirecting SolrQueryRequests to another core with Handler

Nicholas Ball

What is the best way to redirect a SolrQueryRequest to another core from
within a handler (custom SearchHandler)?

I've tried to find the SolrCore of the core I want to redirect to and
called the execute() method with the same params but it looks like the
SolrQueryRequest object already has the old core name embedded into it! I
want to do this without making a new request and going through the servlet
etc...

* Note that I had to have an empty core with a special name just to do
this redirection process in the first place, if there is a better way to
proceed with this please let me know too :)

Many thanks for any help you can give,
Nicholas (incunix)
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting SolrQueryRequests to another core with Handler

Erick Erickson
Haven't done this in code myself, but take a look at
MutlCoreJettyExampleTest and the associated base
class, that might give you some pointers....

Best
Erick

On Thu, Jul 19, 2012 at 9:35 PM, Nicholas Ball
<[hidden email]> wrote:

>
> What is the best way to redirect a SolrQueryRequest to another core from
> within a handler (custom SearchHandler)?
>
> I've tried to find the SolrCore of the core I want to redirect to and
> called the execute() method with the same params but it looks like the
> SolrQueryRequest object already has the old core name embedded into it! I
> want to do this without making a new request and going through the servlet
> etc...
>
> * Note that I had to have an empty core with a special name just to do
> this redirection process in the first place, if there is a better way to
> proceed with this please let me know too :)
>
> Many thanks for any help you can give,
> Nicholas (incunix)
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting SolrQueryRequests to another core with Handler

Nicholas Ball

Hey Erick,

Managed to do this in the end by reconstructing a new SolrQueryRequest
with a SolrRequestParsers (method buildRequestFrom()) and then calling
core.execute();
Took some fiddling but seems to be working now! :)

Thanks for the help!
Nick

On Sun, 22 Jul 2012 10:58:16 -0400, Erick Erickson
<[hidden email]> wrote:

> Haven't done this in code myself, but take a look at
> MutlCoreJettyExampleTest and the associated base
> class, that might give you some pointers....
>
> Best
> Erick
>
> On Thu, Jul 19, 2012 at 9:35 PM, Nicholas Ball
> <[hidden email]> wrote:
>>
>> What is the best way to redirect a SolrQueryRequest to another core
from
>> within a handler (custom SearchHandler)?
>>
>> I've tried to find the SolrCore of the core I want to redirect to and
>> called the execute() method with the same params but it looks like the
>> SolrQueryRequest object already has the old core name embedded into it!
I
>> want to do this without making a new request and going through the
>> servlet
>> etc...
>>
>> * Note that I had to have an empty core with a special name just to do
>> this redirection process in the first place, if there is a better way
to
>> proceed with this please let me know too :)
>>
>> Many thanks for any help you can give,
>> Nicholas (incunix)
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting SolrQueryRequests to another core with Handler

Chris Hostetter-3

: Managed to do this in the end by reconstructing a new SolrQueryRequest
: with a SolrRequestParsers (method buildRequestFrom()) and then calling
: core.execute();
: Took some fiddling but seems to be working now! :)

FWIW, i think the simplest way to do something like this would be...

CoreContainer cc = req.getCore().getCoreDescriptor().getCoreContainer()
SolrCore other = cc.getSolrCore("the_other_core_name") {
try {
  LocalSolrQueryRequest oreq = new LocalSolrQueryRequest(other, ...);
  try {
    SolrQueryResponse orsp = new SolrQueryResponse();
    other.execute(oreq, orsp);
    // do something with orsp
  } finally {
    oreq.close();
  }
} finally {
  other.close();
}



-Hoss