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 Jegannathan Mehalingam <mj...@kavisoft.net> on 2012/11/01 05:06:10 UTC
SOLRJ - Error while using CommonsHttpSolrServer
- 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/";
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
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField( "OR", "119.96");
doc2.addField( "M", "1");
doc2.addField( "PT", "94.5946");
doc2.addField( "PY" , "12");
doc2.addField( "LR" , "118");
doc2.addField( "PC", "FST 04/26/12");
doc2.addField( "SN" , "OTHER");
doc2.addField( "CE", "2012-05-04T04:00:00Z");
doc2.addField( "VC", "184");
doc2.addField( "VR", "24563");
doc2.addField( "PR", "4539673");
doc2.addField( "SE", "2012-04-30T04:00:00Z");
doc2.addField( "IE", "2012-05-08T04:00:00Z");
doc2.addField( "ZR", "4539673");
doc2.addField( "PNT", "94.61079");
doc2.addField( "GY", "17");
doc2.addField( "id", "111_1111111_1_11_2");
doc2.addField( "PAR", "359.88");
doc2.addField( "CTE", "2012-04-26T04:00:00Z");
doc2.addField( "LE", "PDS LOCATION");
doc2.addField( "DR", "691");
doc2.addField( "OY", "4");
doc2.addField( "SS", "10");
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
docs.add( doc2 );
UpdateResponse resp = server.add( docs );
System.out.println(resp.getResponse());
server.commit(true, true);
}
catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
When I run this code, I get the following exception:
org.apache.solr.common.SolrException: parsing error
org.apache.solr.common.SolrException: parsing error
at
org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:143)
at
org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:104)
at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:469)
at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:249)
at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:69)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:54)
at SolrIndexClient.indexTest(SolrIndexClient.java:117)
at SolrIndexClient.main(SolrIndexClient.java:139)
Caused by: java.lang.Exception: really needs to be response or result.
not:html
at
org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:134)
Any idea what is going on? I do not see anything in the log file. I am
not sure if my request is even hitting the server. In our
implementation, we need to update the indexes programatically in
near-real time. If we can't do this, then SOLR is unusable for us .
Thanks in advance,
Jegan Mehalingam
Re: SOLRJ - Error while using CommonsHttpSolrServer
Posted by Jegannathan Mehalingam <mj...@kavisoft.net>.
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
>
Re: SOLRJ - Error while using CommonsHttpSolrServer
Posted by Shawn Heisey <so...@elyograg.org>.
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
Re: SOLRJ - Error while using CommonsHttpSolrServer
Posted by Andre Bois-Crettez <an...@kelkoo.com>.
On 11/01/2012 05:06 AM, Jegannathan Mehalingam wrote:
> Here is my code which uses CommonsHttpSolrServer:
>
> String url = "http://localhost:8983/solr/#/solr/update/";
>
your solr url looks wrong, try this :
http://localhost:8983/solr/update/
or maybe this one is you have a core named "solr" :
http://localhost:8983/solr/solr/update/
André
--
André Bois-Crettez
Search technology, Kelkoo
http://www.kelkoo.com/
Kelkoo SAS
Société par Actions Simplifiée
Au capital de € 4.168.964,30
Siège social : 8, rue du Sentier 75002 Paris
425 093 069 RCS Paris
Ce message et les pièces jointes sont confidentiels et établis à l'attention exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce message, merci de le détruire et d'en avertir l'expéditeur.