Search code examples
solrsolrj

Solr Error Uploading File using ContentStreamUpdateRequest


I am using the following solrj code for to index the document.

     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);

However, I am always getting an SolrException right after the request, which says

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"

I am using the latest version of solr 5.1.0. Any ideas?


Solution

  • I fixed the issue by setting the HttpSolrClient to enable multi part post. Ask me how, I don't know. Solr documentation just does not explain things well.

    mHttpSolrClient.setUseMultiPartPost(true);