lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam ” <skyn...@gmail.com>
Subject Re: custom query string parsing?
Date Tue, 10 Apr 2012 18:39:18 GMT
Essentially, this is what I want to do  (I'm extending SearchComponent):

    @Override
    public void process(ResponseBuilder rb) throws IOException {
        final SolrQueryRequest req = rb.req;
        final MultiMapSolrParams requestParams =
SolrRequestParsers.parseQueryString(req.getParamString());
        final SolrParams allParams = req.getParams();
        final SolrParams defaultParams = allParams - requestParams;
        req.setParams(defaultParams + transformToSolrParams(requestParams));
    }

where allParams - requestParams  will give me default,append,invariant
query params. And, I manually transform requestParams to proper SolrParams,
and sum them up with defaultParams.







On Tue, Apr 10, 2012 at 11:46 AM, sam ” <skynare@gmail.com> wrote:

> I would like to transform the following:
>
> /myhandler/?colors=red&colors=blue&materials=leather
>
> to a Query that is similar to:
> /select/?fq:colors:(red OR
> blue)&fq:materials:leather&facet=on&facet.field=....  and various default
> query params.
>
> I tried to do this by providing QParserPlugin:
>   <queryParser name="myQueryParser" class="my.QueryParserPlugin"/>
>   <requestHandler name="/myhandler" class="solr.SearchHandler">
>      <lst name="defaults">
>          <!-- various default params -->
>          <str name="defType">myQueryParser</str>
>      </lst>
>   </requestHandler>
>
>
> In my.QueryParser (returned by my.QueryParserPlugin) I can:
>     getReq().getParamString();
>
> and parse that string to get non-default SolrParams.
> And, build a Query object to my liking.
>
> Am I going about the right direction?  It'd be much easier if I could
> place a custom app proxying solr... But, I am required to expose solr to
> the public without middle layer between the browsers and solr.
>
> So, my idea is to reject all solr query params but handful of custom
> params such as colors, materials, ..   and build a Query object myself
> combining with default SolrParams specified in solrconfig.xml .
>
> Is this feasible?  I don't really like to parse query string myself
> (returned by getReq().getParamString()) ..
> getReq().getParams()  returns DefaultSolrParams, which does provide a way
> to get non-default params only.
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message