简体   繁体   English

Solr PHP客户端的方面

[英]Faceting with solr php client

I am trying to get the faceting results and I don't know how. 我正在尝试获取多方面的结果,但我不知道如何。 there are no documentation for solr-php-client . 没有solr-php-client文档。 In this example, print_r( $response->getRawResponse() ) does not include faceting. 在此示例中, print_r( $response->getRawResponse() )不包括print_r( $response->getRawResponse() )面。 I am not sure weather faceting is not successfully requested or it is a matter of accessing the faceting data in the responce. 我不确定是否未成功请求天气方面,或者不确定是否在响应中访问方面数据。 Please also help me if there is any documentation available online for solr-php-client . 如果有关于solr-php-client在线文档,也请帮助我。

An other question is how to declare "user/password" if solr is protected when initiating the instance of solr-php-client 另一个问题是在启动solr-php-client实例时,如果solr受保护,如何声明“用户名/密码”

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

我错过了将$additionalParameterssearch争论中;

 $response = $solr->search( $query, $offset, $limit,$additionalParameters );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM