I am using the default solr.xml that came with the installation. The
core name is defined as "solr". So, I changed the url to
"http://localhost:8983/solr/solr/" and that resolves the issue. I also
replaced CommonsHttpSolrServer with HttpSolrServer and this works as
well. I tried both XMLResponseParser as well as the default binary
parser. Both of them works as expected.
Thanks,
Jegan
On 11/1/2012 2:10 AM, Shawn Heisey wrote:
On 10/31/2012 10:06 PM, Jegannathan Mehalingam wrote:
- I tried using HttpSolrServer, but had some problems and some news
groups mentioned that it is buggy and I should be using
CommonsHttpSolrServer. So, I am using CommonsHttpSolrServer. But both
approaches does not work.
- I have tried using SOLR 4.0 as well as 3.6.1. I get errors in both
cases.
- I started SOLR server from C:\apche_solr\apache-solr-4.0.0\example
using the command "java -Dsolr.solr.home="./example-DIH/solr/" -jar
start.jar 1>logs/dih.log 2>&1"
Here is my code which uses CommonsHttpSolrServer:
String url = "http://localhost:8983/solr/#/solr/update/";
This right here is your problem. The URL you have given here is a URL
for the 4.0 admin interface. Chances are what you really want is
this, replacing CORENAME with the actual name of your core:
String url = "http://localhost:8983/solr/CORENAME/";
try {
CommonsHttpSolrServer server = new CommonsHttpSolrServer( url );
server.setSoTimeout(1000); // socket read timeout
server.setConnectionTimeout(100);
server.setDefaultMaxConnectionsPerHost(100);
server.setMaxTotalConnections(100);
server.setFollowRedirects(false); // defaults to false
server.setAllowCompression(false);
server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
server.setParser(new XMLResponseParser()); // binary parser is used
by default
Go with HttpSolrServer. There are problems with it on SolrJ 3.6.0,
but I think they are fixed in 3.6.1. CommonsHttpSolrServer doesn't
exist at all in SolrJ 4.0.
XMLResponseParser is *ONLY* required if your Solr and SolrJ versions
are wildly different. The javabin format changed version number
between 1.4.1 and 3.1.0, and the two versions are completely
incompatible. If both ends are on 3.1 or later, javabin is fine. XML
is slightly slower than javabin.
Most of the SolrJ options you have set here are unnecessary. Unless
you run into an actual problem with the low level TCP/HTTP settings,
the only ones you should initially have are setConnectionTimeout and
setMaxRetries. You've configured a connection timeout of 100
milliseconds. In perfect conditions on a LAN, this is enough, but if
conditions are less than ideal, it may not be. I personally use a
value of 15000, but you may want to go with 5000. Your setMaxRetries
looks appropriate, and is the value that I use. I would lose all the
other options.
Thanks,
Shawn