BiCen
BiCen

Reputation: 61

Bad Request Error When attempting to add documents to server through Solrj

I'm trying to do a simple SolrDocument submission with Java like the one detailed in the Solrj Wiki. However, the submission always fails and returns this:

org.apache.solr.common.SolrException: Bad Request
Bad Request
request: http://address:port/solr/update?wt=xml&version=2.2

I do not run into any issues when querying the Solr server through Solrj, so I don't think there are any problems with the address or connection.

apologizes if this is too vague, but this is all I have to go on. Thanks.

Upvotes: 6

Views: 14704

Answers (5)

Kal K.
Kal K.

Reputation: 1

go to your solr admin page then press logging. check for undefined field error and add that field to the schema.xml and restart solr

Upvotes: -1

tar
tar

Reputation: 1568

If possible, try to connect using CloudSolrServer instead of HttpSolrServer so you can figure out what's wrong with less effort. I have found that the latter will give you this exception that contains no clues as to how the request was "bad", while the former will have more details.

HttpSolrServer exception for missing required field f:

org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Bad Request

CloudSolrServer exception for the same thing:

org.apache.solr.client.solrj.impl.CloudSolrServer$RouteException: [doc=1] missing required field: f

Upvotes: 0

Babu
Babu

Reputation: 5260

I had the same problem, exception says that something is bad with schema.xml but does not says what is the root cause. Check your server log (for me it is tomcat log because I run solr with tomcat), there are logged exceptions from the solr side.

For example my issue was this:

SEVERE: org.apache.solr.common.SolrException: ERROR: [doc=XXXDOCURL] multiple values encountered for non multiValued field XXXMYFILED:

files to check:

  • $SOLR_HOME/$CORE_HOME/conf/schema.xml
  • $NUTCH_HOME/runtime/local(or deploy)/conf/solr-mapping.xml

Well the problem wasn't the schema.xml, but my code. I tried two times nutchDocument.add(XXXMYFIELD,"some value") so for solr it looks like multivalue.

Upvotes: 0

thiagoh
thiagoh

Reputation: 7418

Some of your fields might be wrong according to your schema.xml. Besides seek if there is more than one schema.xml in the classpath your server might be loading the wrong before the correct one.

Upvotes: 2

dongpf
dongpf

Reputation: 1597

I run into this issue before, my problem is solr document is not valid with the fields defined in schema.xml. So make the fields and types match, and problem will be fixed.

Upvotes: 8

Related Questions