Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不断得到一个“答案”;缺少内容流“;使用php和curl发布XML时出错_Php_Xml_Curl_Solr - Fatal编程技术网

不断得到一个“答案”;缺少内容流“;使用php和curl发布XML时出错

不断得到一个“答案”;缺少内容流“;使用php和curl发布XML时出错,php,xml,curl,solr,Php,Xml,Curl,Solr,我试图让php在wiki文章内容发生变化时发布到solr服务器。这是SOLR版本4.4.0、PHP5.3.3和Curl7.19.7 有人有什么想法吗? 谢谢 皮特 以下是PHP代码 $header = array("Content-Type: text/xml; charset=UTF-8"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://wiki.XXXXX.com:8080/solr/update?wt=json&

我试图让php在wiki文章内容发生变化时发布到solr服务器。这是SOLR版本4.4.0、PHP5.3.3和Curl7.19.7

有人有什么想法吗? 谢谢 皮特

以下是PHP代码

$header = array("Content-Type: text/xml; charset=UTF-8");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://wiki.XXXXX.com:8080/solr/update?wt=json&indent=true");        
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,  $encoded);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
$result = curl_exec($ch);
这是错误信息

DEBUG - 2014-05-07 09:18:22.028; org.apache.solr.update.processor.LogUpdateProcessor; PRE_UPDATE FINISH {indent=true&wt=json&<add><doc>
<field type='string'+name%3D'segment'>100000000</field>%0a<field+type%3D'string'+name%3D'digest'>ed226ec873a622e54e26c0eb31f18e2f</field>%0a<field+type%3D'float'+name%3D'boost'>0</field></field>%0a<field+type%3D'text_general'+name%3D'content'>*+goofball%0a*+goofy</field>%0a<field+type%3D'text_general'+name%3D'title'>SolrIndexArticle+Test</field>%0a<field+type%3D'string'+name%3D'author'>Polsen</field>%0a<field+type%3D'long'+name%3D'_version_'></field>%0a</doc></add>%0a<commit+waitFlush%3D'false'+waitSearcher%3D'false'/>%0a}
INFO  - 2014-05-07 09:18:22.028; org.apache.solr.update.processor.LogUpdateProcessor; [collection1] webapp=/solr path=/update params={indent=true&wt=json&<add><doc>
<field type='string'+name%3D'segment'>100000000</field>%0a<field+type%3D'string'+name%3D'digest'>ed226ec873a622e54e26c0eb31f18e2f</field>%0a<field+type%3D'float'+name%3D'boost'>0</field>%0a<field+type%3D'url'+name%3D'host'>HOST URL</field>%0a<field+type%3D'url'+name%3D'url'>URL ID</field>%0a<field+type%3D'url'+name%3D'id'>URL ID</field>%0a<field+type%3D'text_general'+name%3D'content'>*+goofball%0a*+goofy</field>%0a<field+type%3D'text_general'+name%3D'title'>SolrIndexArticle+Test</field>%0a<field+type%3D'string'+name%3D'author'>Polsen</field>%0a<field+type%3D'long'+name%3D'_version_'></field>%0a</doc></add>%0a<commit+waitFlush%3D'false'+waitSearcher%3D'false'/>%0a} {} 0 12
ERROR - 2014-05-07 09:18:22.029; org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: <strong>missing content stream</strong>
    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:1904)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:659)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:362)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    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:724)
从post到Solr的“缺少内容流”意味着您向Solr发送了一个空文档或根本没有文档。在这种情况下,您似乎正在尝试更新Solr中的某些内容-但是根据此错误,您没有传递任何内容。我也没有在您的代码中看到任何包含或指向要更新的文档的内容-

这些先前的讨论可能有助于:

虽然之前的评论中已经给出了这个解决方案,但我想在这里单独的回答中强调一下

Solr显然会在提供文件的请求中返回“缺少的内容流”,而不提交。返回的错误令人困惑,因为实际提供了内容文件


我在分析使用Solarium客户端执行仅提取请求的类似情况。在尝试切换客户端适配器并确保请求包括所选文件后,我通过添加
$request->setCommit(true)最终成功

我将文档内容作为PUT的一部分发送。您可以在服务器的错误响应中看到内容。还是我误解了数据的真实含义?我认为应该编制索引的是文档的内容。服务器上没有要索引的物理文档。能否将内容添加到代码列表中?试图从错误消息中解析出来更为困难,另外,准确地查看您发布的内容更有帮助。我在您返回的错误消息中没有看到任何或,但这可能是因为它已在错误日志中删除。
1d0166376a3238ad46826ab1ea8ed186http://wiki.XXXX.com/sandbox/index.php/SolrIndexArticle_Test http://wiki.XXXXX.com/sandbox/index.php/SolrIndexArticle_Test *这是一个变化*胡言乱语*new SolrIndexArticle Test Polsen
我在我的url中添加了“commit=true”参数,现在我不再出现“missing content stream”错误,但内容似乎仍然无法搜索。下面是我得到的响应:
{“responseHeader”:{“status”:0,“QTime”:31}
您使用的是什么版本的Solr?waitFlush已被弃用。如果您希望立即搜索此内容,我会尝试softcommit。
[07-May-2014 09:18:22] curr exited okay
[07-May-2014 09:18:22] Data returned...
[07-May-2014 09:18:22] ------------------------------------
[07-May-2014 09:18:22] HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Content-Type: text/plain;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 07 May 2014 13:18:22 GMT
Connection: close

{
  "responseHeader":{
    "status":400,
    "QTime":12},
  "error":{
    "msg":"missing content stream",
    "code":400}}