我正试图获得切面结果而我不知道如何。 solr-php-client
没有文档。在此示例中,print_r( $response->getRawResponse() )
不包括分面。我不确定天气方面是否未成功请求,或者是访问响应中的分面数据。如果solr-php-client
在线提供任何文档,请帮助我。
另一个问题是,如果在启动solr-php-client
require_once( 'solr-php-client/Apache/Solr/Service.php' );
$solr = new Apache_Solr_Service( 'localhost', '8983', '/solr/products' );
if ( ! $solr->ping() ) {
echo 'Solr service not responding.';
exit;
}
$offset = 0;
$limit = 10;
$queries = array(
'name:iphone'
);
$additionalParameters = array(
'facet' => 'true',
'facet.field' => array(
'category'
)
);
foreach ( $queries as $query ) {
$response = $solr->search( $query, $offset, $limit );
if ( $response->getHttpStatus() == 200 ) {
print_r( $response->getRawResponse() );
if ( $response->response->numFound > 0 ) {
echo "$query <br />";
foreach ( $response->response->docs as $doc ) {
echo "$doc->id $doc->name <br />";
}
echo '<br />';
}else{
echo "zero results";
}
}
else {
echo $response->getHttpStatusMessage();
}
}
答案 0 :(得分:0)
我错过了将$additionalParameters
添加到search
辩论中;
$response = $solr->search( $query, $offset, $limit,$additionalParameters );