====== Exemple de còde requesta SOLR en php ======
===== fichièr bootstrap.php =====
===== fichièr main.php =====
SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
// 'wt' => SOLR_OUPUT_FORMAT,
'path' => SOLR_PATH,
);
try{
$client = new SolrClient($options);
}catch (Exception $e){
print ("Exception levée. " . $e->getCode() . "\n");
return;
}
$opt = $client->getOptions();
// print_r($opt);
$query = new SolrQuery();
$query->setQuery('pomme');
$query->setStart(0);
$query->setRows(SOLR_MAX_ROW);
$query->addField('definition')
->addField('dictionary')
->addField('genregram')
->addField('term')
->addField('term_clean')
->addField('weight');
try{
$query_response = $client->query($query);
}catch(Exception $e){
print("Exception levée : " . $e->getCode(). "\n");
return;
}
$response = $query_response->getResponse();
$numFound = $response['response']['numFound'];
print ("# trouvés $numFound\n");
$docs = $response['response']['docs'];
foreach ($docs as $solrObj){
$dictionary = $solrObj['dictionary'][0];
$term = $solrObj['term'];
$term_clean = $solrObj['term_clean'];
$genregram = $solrObj['genregram'][0];
$weight = $solrObj['weight'];
$definition = $solrObj['definition'][0];
print ("dictionary : $dictionary, term : $term, term_clean : $term_clean, genregram : $genregram, weight : $weight\ndefinition : $definition\n");
} // foreach
// print_r($response);
?>