运行索引时出现以下错误。我正在使用 Solr 1.4。自 1 天以来,我一直在努力了解其根本原因,但不能。请帮我解决这个问题。
Caused by: org.apache.solr.client.solrj.SolrServerException:
org.apache.commons.httpclient.ProtocolException: Unbuffered entity enclosing request can not be repeated.at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:469) at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243) at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105) at
org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:49)
... 3 more
Caused by: org.apache.commons.httpclient.ProtocolException: Unbuffered entity enclosing request can not be repeated. at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:487) at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:416)
... 7 more
这是代码:
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
CommonsHttpSolrServer server = new CommonsHttpSolrServer(solrHost);
server.setDefaultMaxConnectionsPerHost(150);
server.setRequestWriter(new BinaryRequestWriter());
SolrInputDocument solrDoc = new SolrInputDocument();
solrDoc.addField("id", "1234");
docs.add(solrDoc);
try {
server.add(docs);
server.commit();
} catch (SolrServerException e) {
throw new SolrException(e.getMessage());
}