Corentin
Corentin

Reputation: 325

Solr Exception : org.apache.solr.common.SolrException: missing content stream

I got this exception :

SEVERE: org.apache.solr.common.SolrException: missing content stream
    at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:69)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1817)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:639)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:345)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:141)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:365)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
    at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:642)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
    at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:722)

I try to index some CSV files using CURL. First I've tried this in shell :

 curl http://localhost:8080/solr/update/csv -F "stream.file=/home/usersolr/Data/production/MyFile_1373882442023" -F  "commit=true" -F "header=false" -F "fieldnames=`cat /home/usersolr/Data/header/My_header`"

and it works because, I got the response:

<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">1782</int></lst>
</response>

Then, I wanted to integrate this command line within my Java application, I've written this code :

    Runtime runtime = Runtime.getRuntime();
    String cmd = "curl http://localhost:8080/solr/update/csv -F \"stream.file=/home/usersolr/Data/production/MyFile_1373882442023\" -F  \"commit=true\" -F \"header=false\" -F \"fieldnames=`cat /home/usersolr/Data/header/My_header`\"";          
    System.out.println(cmd);
    runtime.exec(cmd);

And I got the SolrException:

org.apache.solr.common.SolrException: missing content stream.

And my document isn't indexed. The cmd string that I display in the console is exactly the same that the shell command above.

I don't manage the getInputStream() and getOutputStream() methods. Is it linked to my problem?

Thanks

Upvotes: 1

Views: 4070

Answers (2)

Krishan Gopal
Krishan Gopal

Reputation: 4133

Looks like your input to the URL is not being submitted thus getting "missing content stream" error.

Try following command, it should work.

curl http://localhost:8983/solr/update/csv?stream.file=exampledocs/books.csv&stream.contentType=text/plain;charset=utf-8

NOTE: The full path, or a path relative to the CWD of the running solr server must be used.

Upvotes: 0

ObieMD5
ObieMD5

Reputation: 2657

For runtime.exec you need to have an array of your command like so:

String cmd[] = new String[]{"curl", "http://localhost:8080/solr/update/csv", "-F", "\"stream.file=/home/usersolr/Data/production/MyFile_1373882442023\"", "-F"  "\"commit=true\"", "-F", "\""header=false\"", "-F", "\"fieldnames=`cat /home/usersolr/Data/header/My_header`\""};

Upvotes: 1

Related Questions