PHP函式SolrResponse::getResponse()是用於獲取Solr響應的方法。它返回一個包含Solr響應的關聯陣列。
用法:
public array SolrResponse::getResponse( void )
示例:
// 建立Solr客戶端
$client = new SolrClient([
'hostname' => 'localhost',
'port' => 8983,
'path' => '/solr/'
]);
// 建立查詢
$query = new SolrQuery('search term');
// 執行查詢
$response = $client->query($query);
// 獲取Solr響應
$result = $response->getResponse();
// 列印結果
print_r($result);
在上面的示例中,我們首先建立了一個Solr客戶端,然後建立了一個查詢物件。透過呼叫$client->query($query)
來執行查詢,並將結果儲存在$response
變數中。最後,我們呼叫$response->getResponse()
來獲取Solr的響應,並將結果儲存在$result
變數中。最後,我們使用print_r()
函式列印結果。
請注意,該函式適用於PHP Solr擴充套件版本4.0.0及以上。