Hi all!

Just sharing the solution)

I've extended SolrDispatchFilter with my own implementation and did like this:

...

String core = determineCore(req);
super.doFilter(new CoreRoutingReqWrapper(req, core), response, chain);

...

code for the CoreRoutingReqWrapper class:

class CoreRoutingReqWrapper extends HttpServletRequestWrapper {
        private String pathToCore;

public CoreRoutingReqWrapper(HttpServletRequest request, String core) {
            super(request);
            pathToCore = "/" + core + request.getServletPath();
        }

        @Override
        public String getServletPath() {
            return pathToCore;
        }
    }

Would be nice to have something like CoreResolver component in Solr architecture.

Something like this:

interface CoreResolver {
        String resolveCore(HttpServlerRequest req);
}

Would make Solr server more customizable.

What do you think?

Thanx,


: as I said we have our own search handler (wrapping handleRequestBody method : and adding logic before it) where we convert those custom_paramX params into : Solr understandable params like q, fq, facet, etc. Then we delegate to Solr to
: process them.
:
: So what I want to do is core0 handle things if custom_param1=aaa and core1 if
: custom_param1=ccc.

Ah.. i think i'm understanding:
 * you know you need a custom search handler
 * you have a custom search handler that delegates to some other handler
based on some logic
 * your customer handler modifies the request params before delegating to
the handler it picks.
 * the part you are missing is how to delegate to an entirely differnet
SolrCore.

does that capture your question?

The nutshell is you would need to ask your current SolrCore for access to
the CoreContainer -- then create a new "LocalSolrQueryRequest" and ask
that SolrCore to execute it.  one hitch to watch out for is keeping track
of thinkgs like the SolrIndexSearcher used -- because stuff like "DocList"
values in the response will come from the *other* SolrIndexSearcher, and
you'll need to use that when writting the response out (because the
QueryResponseWriter needs to as the SolrInexSearcher for the stored fields
from those docids).

(Note: i have never tried this ... there may be other gotcha's i'm not
aware of)






-Hoss


--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to