You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Shawn Heisey <so...@elyograg.org> on 2012/01/04 19:03:47 UTC

Detecting query errors with SolrJ

When doing Solr queries in a browser, it's pretty easy to see an HTTP 
error status and read the reason, but I would like to do the same thing 
in a deterministic way with SolrJ.  Can anyone point me to examples that 
show how to retrieve the HTTP status code and the reason for the error?  
I would like to inform the end user that there was a problem and offer 
ideas about how they might be able to fix it, rather than simply show an 
empty result grid.

Thanks,
Shawn


Re: Detecting query errors with SolrJ

Posted by Michael Sokolov <so...@ifactory.com>.
It's possible this may have changed in a recent release, and I don't 
know about it, but when I last checked, the only information you could 
get out of solrj was a SolrServerException with some very limited info - 
basically - an error occurred on the server, and maybe HTTP 400.

When you say you see it in the browser, do you mean in the solr admin 
webapp?  If so, that's being generated in solr, and not transmitted via 
javabin to solrj.

Erick - I don't know if you're (still) following this thread, but this 
is an area that could really use some attention, I think, from a 
committer.  It's relatively straightforward to fix, and will make a 
substantial improvement for solrj users.  If you're still looking for 
tickets to push forward :)

-Mike

On 1/8/2012 4:41 PM, Shawn Heisey wrote:
> On 1/6/2012 3:57 PM, Michael Sokolov wrote:
>> See SOLR-141; there are a few patches - currently all you get back is 
>> a 400 error with no actual information equivalent to what is logged 
>> in the solr exception.
>
> If I can get the HTTP code and the text that's in the error you see in 
> the browser, that's good enough.  I just need to know how to get it.  
> I didn't see any code in SOLR-141 for how to do this.  Having the full 
> exception would be nice, but not really necessary.
>
> Thanks,
> Shawn
>


Re: Detecting query errors with SolrJ

Posted by Shawn Heisey <so...@elyograg.org>.
On 1/6/2012 3:57 PM, Michael Sokolov wrote:
> See SOLR-141; there are a few patches - currently all you get back is 
> a 400 error with no actual information equivalent to what is logged in 
> the solr exception.

If I can get the HTTP code and the text that's in the error you see in 
the browser, that's good enough.  I just need to know how to get it.  I 
didn't see any code in SOLR-141 for how to do this.  Having the full 
exception would be nice, but not really necessary.

Thanks,
Shawn


Re: Detecting query errors with SolrJ

Posted by Michael Sokolov <so...@ifactory.com>.
See SOLR-141; there are a few patches - currently all you get back is a 
400 error with no actual information equivalent to what is logged in the 
solr exception.

On 1/6/2012 12:46 PM, Shawn Heisey wrote:
> On 1/5/2012 7:25 AM, Erick Erickson wrote:
>> Somewhere you have access to a CommonsHttpSolrServer, right? There's a
>> getHttpClient call that returns an org.apache.commons.httpclient that
>> might get you the information you need.
>
> If I have a multithreaded app that shares a single HttpClient between 
> different server objects (or another that uses one server object for 
> all queries), will I have a prayer of getting this information out of 
> the shared client object before another request overwrites the 
> information I require?  I was really hoping it would be in the 
> response object.
>
> Thanks,
> Shawn
>


Re: Detecting query errors with SolrJ

Posted by Shawn Heisey <so...@elyograg.org>.
On 1/5/2012 7:25 AM, Erick Erickson wrote:
> Somewhere you have access to a CommonsHttpSolrServer, right? There's a
> getHttpClient call that returns an org.apache.commons.httpclient that
> might get you the information you need.

If I have a multithreaded app that shares a single HttpClient between 
different server objects (or another that uses one server object for all 
queries), will I have a prayer of getting this information out of the 
shared client object before another request overwrites the information I 
require?  I was really hoping it would be in the response object.

Thanks,
Shawn


Re: Detecting query errors with SolrJ

Posted by Erick Erickson <er...@gmail.com>.
Shawn:

Somewhere you have access to a CommonsHttpSolrServer, right? There's a
getHttpClient call that returns an org.apache.commons.httpclient that
might get you the information you need.

Best
Erick

On Wed, Jan 4, 2012 at 1:03 PM, Shawn Heisey <so...@elyograg.org> wrote:
> When doing Solr queries in a browser, it's pretty easy to see an HTTP error
> status and read the reason, but I would like to do the same thing in a
> deterministic way with SolrJ.  Can anyone point me to examples that show how
> to retrieve the HTTP status code and the reason for the error?  I would like
> to inform the end user that there was a problem and offer ideas about how
> they might be able to fix it, rather than simply show an empty result grid.
>
> Thanks,
> Shawn
>