Hi all,

At first, lucene user for years, I should really thanks you for Solr.

For a start, I wrote a little results writer for an app. It works like what I understand of Solr, except a strange exception I'm not able to puzzle.

Version : fresh subversion.
 1. Class
 2. stacktrace
 3. maybe ?

1. Class
========

public class HTMLResponseWriter implements QueryResponseWriter {
  public static String CONTENT_TYPE_HTML_UTF8 = "text/html; charset=UTF-8";
  /** A custom HTML header configured from solrconfig.xml */
  static String HEAD;
  /** A custom HTML footer configured from solrconfig.xml */
  static String FOOT;

  /** get some snippets from conf */
  public void init(NamedList n) {
    String s=(String)n.get("head");
    if (s != null && !"".equals(s)) HEAD = s;
    s=(String)n.get("foot");
    if (s != null && !"".equals(s)) FOOT = s;
  }

public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp)
      throws IOException {
    // cause the exception below
    writer.write(HEAD);
    /* loop on my results, working like it should */
    // cause the exception below
    writer.write(FOOT);
  }

public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {
    return CONTENT_TYPE_HTML_UTF8;
  }

}

2. Stacktrace
=============

GRAVE: org.apache.solr.core.SolrException: Missing required parameter: q
at org.apache.solr.request.RequiredSolrParams.get(RequiredSolrParams.java:50) at org.apache.solr.request.StandardRequestHandler.handleRequestBody(StandardRequestHandler.java:72) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:77)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:658)
        at org.apache.solr.servlet.SolrServlet.doGet(SolrServlet.java:66)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
...

3. Maybe ?
==========

I can't figure why, but when writer.write(HEAD) is executed, I see code from StandardRequestHandler executed 2 times in the debugger, first is OK, second hasn't the q parameter. Displaying results is always OK. Without such lines, there is only one call to StandardRequestHandler, no exception in log, but no more head or foot. When HEAD and FOOT values are hard coded and not configured, there's no exception. If HEAD and FOOT are not static, problem is the same.

Is it a mistake in my code ? Every piece of advice welcome, and if I touch a bug, be sure I will do my best to help.

--
Frédéric Glorieux
École nationale des chartes
direction des nouvelles technologies et de l'informatique

Reply via email to