1
votes

I am new to Solr and I am trying to integrate it with my PHP application using Solarium. I tried running the ping query but it is failing and giving Solr HTTP error: Not Found (404) response.

My PHP code is as follows:

    $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();
    }

My Solr server address is :http://localhost:8983/solr/ Core: techproducts

I am getting this output : Client created ping created Solr HTTP error: Not Found (404) Can anyone suggest what can be the possible solutions?

1
check by adding the "/solr/" in the path...Abhijit Bashetti
Tried it. Not working. What does this "path" actually corresponds to? Can anyone explain?Ayush
This is what he meant $config = array( "endpoint" => array("localhost" => array("host"=>"localhost", "port"=>8983, "path"=>"/solr/", "core"=>"techproducts",)));Tismon Varghese
its the contextpath...hows the url get constructed...did you check that...Abhijit Bashetti
@TismonVarghese : you got me correct...Abhijit Bashetti

1 Answers

1
votes

I am guessing that ping handler is missing into your solrconfig.xml file. Please check. You can the below configuration for the same.

<!-- 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>

Then you can ping the solr. You can edit the core name in url. click Here