コード例 #1
0
ファイル: Query.php プロジェクト: hnadler/ext-solr
 /**
  * Activates and deactivates faceting for the current query.
  *
  * @param boolean $faceting TRUE to enable faceting, FALSE to disable faceting
  * @return void
  */
 public function setFaceting($faceting = true)
 {
     if ($faceting) {
         $this->queryParameters['facet'] = 'true';
         $this->queryParameters['facet.mincount'] = $this->solrConfiguration->getSearchFacetingMinimumCount();
         $sorting = $this->solrConfiguration->getSearchFacetingSortBy();
         if (GeneralUtility::inList('count,index,alpha,lex,1,0,true,false', $sorting)) {
             // alpha and lex alias for index
             if ($sorting == 'alpha' || $sorting == 'lex') {
                 $sorting = 'index';
             }
             $this->queryParameters['facet.sort'] = $sorting;
         }
     } else {
         foreach ($this->queryParameters as $key => $value) {
             // remove all facet.* settings
             if (GeneralUtility::isFirstPartOfStr($key, 'facet')) {
                 unset($this->queryParameters[$key]);
             }
             // remove all f.*.facet.* settings (overrides for individual fields)
             if (GeneralUtility::isFirstPartOfStr($key, 'f.') && strpos($key, '.facet.') !== false) {
                 unset($this->queryParameters[$key]);
             }
         }
     }
 }