You are here

function facetapi_luceneapi_terms_count in Facet API 6

Gets the filter counts for an array of terms.

Parameters

$index: A LuceneAPI_Search_Lucene_Proxy object, such as the one returned by the luceneapi_index_open() function.

$docs: An array of documents keyed by docuent ID to score.

$terms: An array of Zend_Search_Lucene_Index_Term objects.

2 calls to facetapi_luceneapi_terms_count()
FacetapiLuceneapiAdapter::fetchDate in contrib/facetapi_luceneapi/facetapi_luceneapi.adapter.inc
Fetches data from facets that filter results by date ranges.
FacetapiLuceneapiAdapter::fetchTerm in contrib/facetapi_luceneapi/facetapi_luceneapi.adapter.inc
The default method used to retrieve facet data.

File

contrib/facetapi_luceneapi/facetapi_luceneapi.cache.inc, line 117
Term frequency cache functions.

Code

function facetapi_luceneapi_terms_count(Zend_Search_Lucene_Proxy $index, array $docs, array $terms) {
  $freqs = array();

  // Reading from a termFreqs cache table is MUCH more efficient than
  // calculating them on the fly for every search.
  foreach ($terms as $term) {
    $freqs += facetapi_luceneapi_termfreqs_get('luceneapi_node', $term);
  }

  // NOTE: This is surprisingly efficient.
  return count(array_intersect_key($docs, $freqs));
}