user1799339
user1799339

Reputation: 65

SolrJ doesn't catch SolrExeption

I'm using solrJ to add docs to my solr index. I see the log from solr throws an exception but when debugging the response from solrJ it doesn't say anything about solr failing. Is there a way for me to get this error in solrJ (Error type: org.apache.solr.common.SolrException)?

Thanks

Upvotes: 1

Views: 451

Answers (1)

elyograg
elyograg

Reputation: 789

If you are using ConcurrentUpdateSolrServer (SolrJ 3.6 and later) or StreamingUpdateSolrServer (3.6 and earlier), there is no error handling for update requests. Update requests always succeed and return immediately, whether Solr is there to accept them or not.Errors are logged but that's it. This happens because the requests are sent to Solr by background threads.

If you need exception handling, use HttpSolrServer (CommonsHttpSolrServer in older releases) instead. The Concurrent/Streaming objects trade error handling for built-in threading. HttpSolrServer is completely threadsafe, but does not use multiple threads internally, so you would need to handle indexing simultaneously with muitiple threads in your own application.

NB: You might be confused by the fact that 3.6 is listed above for both objects. This isn't a typo - the old object types were deprecated in 3.6.0 and removed in 4.0.0.

Upvotes: 2

Related Questions