You are here

public function FacetapiLuceneapiAdapter::fetchTerm in Facet API 6

The default method used to retrieve facet data.

File

contrib/facetapi_luceneapi/facetapi_luceneapi.adapter.inc, line 23
Classes used by the Facet API module.

Class

FacetapiLuceneapiAdapter
Facet API adapter for Search Lucene API modules.

Code

public function fetchTerm(array $facet) {
  $facet_items = array();
  $sql = "\n      SELECT term\n      FROM {" . $this
    ->getSearcher() . "_termfreqs}\n      WHERE field = '%s'\n    ";

  // Gets the cached term frequencies.
  if ($result = db_query($sql, array(
    $facet['field'],
  ))) {
    while ($record = db_fetch_object($result)) {
      $term = new Zend_Search_Lucene_Index_Term($record->term, $facet['field']);
      if ($count = facetapi_luceneapi_terms_count($this->_index, $this->_docs, array(
        $term,
      ))) {
        $facet_items[$record->term] = array(
          'count' => $count,
        );
      }
    }
  }
  return $facet_items;
}