solaris Ping请求错误:Solr HTTP错误:Not Found(404)


Solarium Ping request error : Solr HTTP error: Not Found (404)

我是Solr的新手,我正在尝试将它与使用Solarium的PHP应用程序集成。我试着运行ping查询,但它失败了,并给出Solr HTTP错误:未找到(404)响应。

我的PHP代码如下:
    $config = array(
     "endpoint" => array("localhost" => array("host"=>"localhost",
     "port"=>8983, "path"=>"/solr", "core"=>"techproducts",)));
    try{
    $client = new Solarium_Client($config);
    }catch (Exception $e){
        echo $e->getMessage();
    }
    if ($client == null) {
        echo 'Client null';
    } else {
        echo 'Client created</br>';
        //v($client);
    }
    // create a ping query
    $ping = $client->createPing();
    if ($ping == null) {
        echo 'ping null';
    } else {
        echo 'ping created</br>';
        //v($ping);
    }
    // execute the ping query
    try{
        $result= $client->ping($ping);
        echo 'Ping query successful';
        echo '<br/><pre>';
        //var_dump($result->getData());
    }catch(Solarium_Exception $e){
        echo $e->getMessage();
    }

我的Solr服务器地址是:http://localhost:8983/solr/核心:techproducts

我得到这样的输出:客户端创建平了Solr HTTP错误:Not Found (404)谁能提出可能的解决方案?

我猜ping处理程序缺失到您的solrconfig.xml文件。请查一下。您可以使用下面的配置进行相同的配置。

<!-- ping/healthcheck -->
<requestHandler name="/admin/ping" class="solr.PingRequestHandler">
    <lst name="invariants">
        <str name="q">solrpingquery</str>
    </lst>
    <lst name="defaults">
        <str name="echoParams">all</str>
    </lst>
    <!-- An optional feature of the PingRequestHandler is to configure the
         handler with a "healthcheckFile" which can be used to enable/disable
         the PingRequestHandler.
         relative paths are resolved against the data dir
      -->
    <!-- <str name="healthcheckFile">server-enabled.txt</str> -->
</requestHandler>

然后可以ping solr。您可以在url中编辑核心名称。点击这里