When an indexing request is bad, SolrJ just throws an error message - "Bad 
Request" but does not tell you what about the request was wrong.
-------------------------------------------------------------------------------------------------------------------------------------------

                 Key: SOLR-2527
                 URL: https://issues.apache.org/jira/browse/SOLR-2527
             Project: Solr
          Issue Type: Improvement
          Components: clients - java
    Affects Versions: 1.4.1
         Environment: Windows, Linux 
            Reporter: Saroj Kumar
            Priority: Minor
             Fix For: 1.4.2
         Attachments: solr-bad-req-patch.txt

When an indexing request is bad, SolrJ just throws an error message - "Bad 
Request" but does not tell you what about the request was wrong.

In these cases, developer has to look at the Solr Server logs to find out what 
was bad with request. 
It would be very helpful if SolrJ could show that error message as well. This 
would provide an easy way for developers to troubleshoot.

If you use anything like POSTER or some other tool to post to Solr then you 
would notice that you get the proper error message back from server in the 
response body. It confirms that Solr Server is providing all the debug info to 
client but it is client which is not showing the message.

An example of bad request can be: 
when you are adding a document which is missing a mandatory field.

SolrJ would dump this on console
---------------

Bad Request

request: http://localhost:8080/solr/update?wt=xml&version=2.2
        at 
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:440)
        at 
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:244)
        at 
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
        at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:74)
        at TestClient.main(TestClient.java:50)


If we could provide something like following then it would be more helpful as 
you can easily notice that a mandatory field is missing.

Bad Request

request: http://localhost:8080/solr/update?wt=xml&version=2.2
        at 
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:440)
        at 
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:244)
        at 
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
        at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:74)
        at TestClient.main(TestClient.java:50)


responseBody: 

<html><head><title>Apache Tomcat/6.0.32 - Error report</title><style><!--H1 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
 H2 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
 H3 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
 BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} 
B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P 
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
 {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> 
</head><body><h1>HTTP Status 400 - Document [null] missing required field: 
bus_id_with_bus_unit_sku</h1><HR size="1" noshade="noshade"><p><b>type</b> 
Status report</p><p><b>message</b> <u>Document [null] "missing required field: 
bus_id_with_bus_unit_sku"</u></p><p><b>description</b> <u>The request sent by 
the client was syntactically incorrect (Document [null] missing required field: 
bus_id_with_bus_unit_sku).</u></p><HR size="1" noshade="noshade"><h3>Apache 
Tomcat/6.0.32</h3></body></html>


It is very easy to do this with a minimal change in CommonsHttpSolrServer

Attached is a patch which has the modified code and a test case to assert that 
response body is being shown in the error message




--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to