6

I am new to solr. I have developed a an website which uses solr for indexing. I want to handle the timeouts that can occur during solr read and write index.Please guide me on how can i handle these exceptions. I am using solrj as solr client and my website and solr server are running on the tomcat.

Thnak you!

5
  • When do you get these timeouts? How often are you committing? Check the Solr log, see if there aren't any WARNINGs or ERRORs. May 10, 2010 at 12:23
  • 1
    Hi Maurico, Thanks for your interest! I get these timeouts when i am firing a search query.These exceptions are not too often. I am getting the read timeout exception in my tomcat logs as : org.apache.solr.client.solrj.SolrServerException:java.net.SocketTimeoutException: Read timed out at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243) at org.apache.solr.client.solrj.SolrServer.optimize(SolrServer.java:94) at org.apache.solr.client.solrj.SolrServer.optimize(SolrServer.java:82) ..... ..... May 10, 2010 at 12:48
  • The stack trace says the timeout happens during an optimize operation, not a query... are you optimizing every time you fire a query? May 10, 2010 at 19:03
  • Yes i am optimizing before querrying the solr. Also after the query is fired I am again commiting the server. Should i do this or not? May 11, 2010 at 10:14
  • Hi Mauricio, I tested my code without optimizing the server before firing the query,my prev assumption was wrong.I was not sure whether to optimize it or not.But still can you guide me when to commit the and how often? I am commiting the server when i perform delete or add index to the server.Is it okey? May 11, 2010 at 12:30

1 Answer 1

11

Commit and Optimize are operations to make updates available to searchers. They are intended to be run after updates, not before queries.

Furthermore, they are expensive operations, which is why you're getting sporadical timeouts. Unless you have some special requirements, I recommend setting the <autoCommit/> option in your solrconfig.xml. As the name says, it will automatically issue the commit depending on configurable criteria like maximum number of uncommitted documents or maximum time after adding documents.

Optimize is even more expensive than Commit, it basically rewrites the index. The frequency of an Optimize depends on how often you Commit changes and how many changes there are per commit.

See also:

1
  • Thanks a lot Mauricio. I have got all the doubts cleared and have implemented the accordingly.Now i am using only commits when the solr indexes are to be added or removed. Thanks! May 12, 2010 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.