Solr错误上传文件使用ContentStreamUpdateRequest

Solr Error Uploading File using ContentStreamUpdateRequest

我正在使用以下 solrj 代码来索引文档。

     ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");
     ContentStreamBase.FileStream fs = new FileStream(new File(filename));
     req.setWaitSearcher(false);
     req.setMethod(METHOD.POST );
     //req.addFile(new File(filename), null);
     req.addContentStream(fs);
     req.setParam("literal.id", filename);
     req.setParam("resource.name", filename);
     //req.setParam("uprefix", "attr_");
     //req.setParam("fmap.content", "attr_content");
     //req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
     NamedList<Object> result = this.mHttpSolrClient.request(req);

但是,我总是在请求后立即收到 SolrException,它说

4767120 [qtp559670971-21] INFO  org.apache.solr.update.processor.LogUpdateProcessor  [   test] – [test] webapp=/solr path=/update/extract params={waitSearcher=false&resource.name=/tmp/RUNNING.txt&literal.id=/tmp/RUNNING.txt&wt=javabin&version=2} {} 0 6
4767121 [qtp559670971-21] ERROR org.apache.solr.core.SolrCore  [   test] – org.apache.solr.common.SolrException: ERROR: [doc=/tmp/RUNNING.txt] Error adding field 'stream_size'='null' msg=For input string: "null"

我使用的是最新版本的solr 5.1.0。有什么想法吗?

我通过将 HttpSolrClient 设置为启用多部分 post 解决了这个问题。问我如何,我不知道。 Solr 文档只是不能很好地解释事情。

mHttpSolrClient.setUseMultiPartPost(true);