duanchan9354 2012-10-09 14:41
浏览 22

Solr for PHP:getDigestedResponse无效

I've managed to install Solr for PHP on my Windows 7 64bit Machine using the plugin I found here:

downloads.php.net/pierre/

It was linked to on this site:

wiki.apache.org/solr/SolPHP

(links are not clickable because I'm a new user)

I've got everything up and running, searches and indexing are working, but only when I use the getRawResponse() Method and parse it through SimpleXml (http://de.php.net/manual/en/book.simplexml.php). The getDigestedResponse() method, which ist supposed to return a PHP-Object, just returns string(1) " ". The method getResponse() (http://docs.php.net/manual/en/solrresponse.getresponse.php) just times out.

It wouldn't be that much of a problem, but some of the XML from the Raw Response doesn't seem to be valid and parsed with simpleXML, some of the attributes are missing, using regular expressions to get the needed data would be too much of a hassle.

Has anyone get this to work yet? Help is greatly appreciated!

  • 写回答

1条回答 默认 最新

  • dongyuqi3808 2012-10-13 03:01
    关注

    Depends on how you are parsing the response. Try code below and drop the PHP/PECL solr libs and go CURL (ex: hostNameHere:8983/solr/select/?q=solr&start=0&rows=10&indent=on and send the result XML to the function below).

    If you can access a resource (solr) via a URL, then there is no need to use an ancillary library to do what CURL can do:

    function makeSimpleXML($xml) {
        $dom = new DOMDocument;
        $dom->loadXML($xml);
        if (!$dom) {
            // ErrorUtility::throwFatal("could not parse xml. please check the format", "XMLParisng Error");
        }
        return simplexml_import_dom($dom);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法