PHP Solr giving a Catchable fatal error -


the following code adds documents , fires query using solr.

it's showing error:

solrinputdocument number 1 not valid solrinputdocument instance catchable fatal error: argument 1 passed solrclient::query() must instance of solrparams, string given in /var/www/ps/test.php on line 85   <?php require_once( 'bootstrap.php' ); $options = array( 'hostname' => solr_server_hostname ); $client = new solrclient($options);   // create 2 documents represent 2 auto parts.   $parts = array(     'spark_plug' => array(       'partno' => 1,       'name' => 'spark plug',       'model' => array( 'boxster', '924' ),       'year' => array( 1999, 2000 ),       'price' => 25.00,       'instock' => true,     ),     'windshield' => array(       'partno' => 2,       'name' => 'windshield',       'model' => '911',       'year' => array( 1999, 2000 ),       'price' => 15.00,       'instock' => false,     )   );    $documents = array();    foreach ( $parts $item => $fields ) {     $part = new solrdocument();      foreach ( $fields $key => $value ) {       if ( is_array( $value ) ) {         foreach ( $value $datum ) {           $part->addfield( $key, $datum );         }       }       else {         $part->$key = $value;       }     }      $documents[] = $part;   }    // load documents index   try {     $client->adddocuments( $documents );     $client->commit();     $client->optimize();   }   catch ( exception $e ) {     echo $e->getmessage();   }    // run queries.    $offset = 0;   $limit = 10;    $queries = array(     'partno: 1 or partno: 2',     'model: boxster',     'name: plug'   );    foreach ( $queries $query ) {     $queryresponse = $client->query($query);      if ( $queryresponse->gethttpstatus() == 200 ) {        // print_r( $response->getrawresponse() );        if ( $queryresponse->response->numfound > 0 ) {         echo "$query <br />";          foreach ( $queryresponse->response->docs $doc ) {            echo "$doc->partno $doc->name <br />";         }          echo '<br />';       }     }     else {       echo $queryresponse->gethttpstatusmessage();     }   } ?> 


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -