[ 
http://issues.apache.org/jira/browse/SOLR-59?page=comments#action_12447024 ] 
            
Yonik Seeley commented on SOLR-59:
----------------------------------

> I agree, but I'm not sure how to access these values, are they provided 
> somewhere in SolrCore, or how should I best get them?

You must have them... you added them to the header ;-)
After a request handler is called, it will have added default parameters to the 
SolrQueryRequest oblect.... so you can just use 
req.getParams().get("echoParams")

This could be done in SolrCore.exec() or in a utility function that all 
ResponseWriters call to get the header data.

I just peeked at your code now...
An alternative to adding additional methods to SolrQueryResponse to hold the 
headers is to just treat the headers like any other data object in the 
response.  That would also allow request handlers to add stuff to the header in 
the future (if they really needed to):

So SolrCore.execute could look something like this perhaps:

  public void execute(SolrQueryRequest req, SolrQueryResponse rsp) {
    SolrRequestHandler handler = getRequestHandler(req.getQueryType());
    if (handler==null) {
      log.warning("Unknown Request Handler '" + req.getQueryType() +"' :" + 
req);
      throw new SolrException(400,"Unknown Request Handler '" + 
req.getQueryType() + "'", true);
    }
    NamedList responseHeader = new NamedList();
    rsp.add("responseHeader", responseHeader);
    handler.handleRequest(req,rsp);
    int qtime=(int)(rsp.getEndTime() - req.getStartTime());
    // might want to re-get responseHeader here, or mandate that request handers
    // do not *replace* the responseHeader in the SolrQueryResponse they are 
handed.
    responseHeader.add("status",rsp.getException()==null ? 0 : 500);
    responseHeader.add("QTime",qtime);
    // Values for echoParams... false/true/all or false/explicit/all ???
    if ("explicit".equals(req.getParams().get("echoParams")))
        responseHeader.add("params", asNamedList_TBD(req.getOriginalParams()));
    log.info(req.getParamString()+ " 0 " + qtime);
  }


> Copy request parameters to Solr's response
> ------------------------------------------
>
>                 Key: SOLR-59
>                 URL: http://issues.apache.org/jira/browse/SOLR-59
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Bertrand Delacretaz
>         Attachments: SOLR-59-20061024.patch, SOLR-59-20061102.patch, 
> SOLR-59-20061103.patch, SOLR-59-new-files-20061102.tar.gz
>
>
> This patch copies the request parameters (explicit ones only, not the 
> defaults) to Solr's XML output.
> It is not configurable yet, it is enabled by default and adds a 
> "queryParameters" list to the responseHeader:
> <responseHeader>
>         <status>0</status>
>         <QTime>1</QTime>
>         <lst name="queryParameters">
>                 <arr name="multi">
>                         <str>red</str>
>                         <str>blue</str>
>                 </arr>
>                 <str name="rows">10</str>
>                 <str name="start">0</str>
>                 <str name="indent">on</str>
>                 <str name="q">solr</str>
>                 <str name="stylesheet"/>
>                 <str name="version">2.1</str>
>         </lst>
> </responseHeader>
> The above example includes a multi-valued parameter, "multi".
> This might still change a bit, but if someone wants to play with it or 
> improve it, here you go.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to