solariumphp / solarium

PHP Solr client library
Other
932 stars 302 forks source link

extract query error: the request was rejected because no multipart boundary was found #301

Closed seanchen closed 6 years ago

seanchen commented 9 years ago

Hi,

I am using the example code to test the Solarium Extract query on the following configuration:

I always got the following Exception on Tomcat / Solr:

SEVERE: null:org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
        at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:931)
        at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:349)
        at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
        at org.apache.solr.servlet.MultipartRequestParser.parseParamsAndFillStreams(SolrRequestParsers.java:344)
        at org.apache.solr.servlet.StandardRequestParser.parseParamsAndFillStreams(SolrRequestParsers.java:397)
        at org.apache.solr.servlet.SolrRequestParsers.parse(SolrRequestParsers.java:115)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

I did try to use PHP curl POST directly, it is working fine. Which tells the Solr config should be correct...

Not sure why the Extract query not working? Did I missing anything?

Thanks,

-Sean

basdenooijer commented 9 years ago

It's hard to say without more info. Could you for instance show how you execute the Solarium query, and how you construct the curl request?

seanchen commented 9 years ago

Hi basdenooijer,

thanks a lot for your reply! please check the following code.

I am using Solarium in a WordPress plugin. And we are using the Solarium update query for quite some time. It is working pretty well.

Thanks,

-Sean

Here is the Extract query, which failed on Solr side with the no multipart boundary exception.

// get a solarium client.
$client = new Solarium\Client($config);
// create extract handler...
$extractQuery = $client->createExtract();
// mapping between tika and solr schema.
$mappingArray=array(
    "content_type" => "type",
    "author" => "authors",
    "last_modified" => "lastModifiedDate",
    "creation_date" => "creationDate",
    "content" => "content"
);
$extractQuery->addFieldMappings($mappingArray);
// is this the absolute path to the file.
$fpath = '/var/www/html/readme.html';
$extractQuery->setUprefix('ignored_');
$extractQuery->setCommit(true);
$extractQuery->setOmitHeader(false);
$extractQuery->setFile($fpath);
// hard-coded meta data for testing ...
$doc = $extractQuery->createDocument();
$doc->id = 'testing-1234';
$doc->site = 'mysite';
$doc->description = 'testing description';
$doc->url = 'http://example.url.com';
$doc->title = 'testing title';
$extractQuery->setDocument($doc);
try {
     echo '<b>Total Result</b><br/>';
     $result = $client->extract($extractQuery);
     echo '<b>Extract query executed</b><br/>';
     echo 'Query status: ' . $result->getStatus(). '<br/>';
     echo 'Query Time: ' . $result->getQueryTime(). '<br/>';
} catch (Exception $e) {
     echo "<b>Execptions</b><br/>";
     echo "<pre>";
     var_dump($e);
     echo "</pre>";
}

Here is the php curl request, which go through solr successfully.

// try to use Curl directly:
$mapping_array=array(
        "literal.id"                    => 'id-curl-testing-docx',
        "literal.site"                  => 'site',
        "literal.description"           => 'description',
        "literal.url"                   => 'url',
        "literal.title"                 => 'title',
        "fmap.content_type"             => "type",
        "fmap.author"                   => "authors",
        "fmap.last_modified"    => "lastModifiedDate",
        "fmap.creation_date"    => "creationDate",
        "fmap.content"                  => "content",
        "commit"                                => "true"
);
$fpath = '/var/www/html/readme.html';
//Initiate the Curl
$ch = curl_init();
$solr_extraction_endpoint = "http://10.1.1.1:8088/search/wp-bin/update/extract";
// Setting up for no data to print out, also set it to submit via POST
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, ($solr_extraction_endpoint . '?' . http_build_query($mapping_array,'','&')));
$cfile = curl_file_create($fpath);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => $cfile));

//Execute curl.
if(!curl_exec($ch) == TRUE)
{
    throw new Exception('Curl Error:' . curl_error($ch));
    echo "<br/>Curl Error:<br/>" . curl_error($ch);
}
curl_close($ch);
cristiroma commented 8 years ago

We are having a similar issue, when using the Http adapter the boundary parameter is missing from the content-type header (https://github.com/solariumphp/solarium/blob/master/library/Solarium/Core/Client/Adapter/Http.php#L120), but I'm not sure how to fix it.

:+1:

seanchen commented 8 years ago

@cristiroma,

It seems has not been fixed yet. I get walk around by using the URL to the file instead of the file path. In my case here, it is easy to get the URL of the binary file. And Solr handles URL resources very well.

You fix #413 looks good! It is good idea. I think the CI test failed because of the missing Solr instance...

thanks,

-Sean

ashutosh049 commented 7 years ago

I'm facing same issue.

Got any solution ??

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:165) at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142) at org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:108) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:990) at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310) at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334) at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115) at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:158) ... 20 more

cristiroma commented 7 years ago

@ashutosh049 did you tried the fix from #413?

ashutosh049 commented 7 years ago

I tried

ashutosh049 commented 7 years ago

contentType : 'application/json; charset=UTF-8;boundary=gc0p4Jq0M2Yt08jU534c0p', and this worked

eshiett1995 commented 7 years ago

@ashutosh049 i am confused. i want send a multipart file....but then i am getting a " the request was rejected because no multipart boundary was found". please how do i solve this