function facetapi_luceneapi_facetapi_query_term_process in Facet API 6
Implementation of hook_facetapi_query_TYPE_process().
File
- contrib/
facetapi_luceneapi/ facetapi_luceneapi.module, line 161 - The Search Lucene API module's implementation of the the Facet API.
Code
function facetapi_luceneapi_facetapi_query_term_process(FacetapiAdapter $adapter, array $facet, Zend_Search_Lucene_Search_Query $query) {
$values = $adapter
->getActiveFacets($facet['field alias']);
if (empty($values)) {
return;
}
try {
if (!($multiterm = luceneapi_query_get('multiterm'))) {
throw new LuceneAPI_Exception(t('Error instantiating multiterm query.'));
}
// Gets the operator.
$operator = facetapi_setting_get('operator', $adapter
->getSearcher(), '', $facet['name']);
$sign = FACETAPI_OPERATOR_OR != $operator ? 'required' : 'neither';
foreach ($values as $value => $filter_string) {
$term = luceneapi_term_get((string) $value, $facet['field'], TRUE);
luceneapi_term_add($multiterm, $term, $sign, TRUE);
}
// If there are terms, appends subquery.
if (count($multiterm
->getTerms())) {
$multiterm
->setBoost(LUCENEAPI_IRRELEVANT);
luceneapi_subquery_add($query, $multiterm, 'required', TRUE);
}
} catch (LuceneAPI_Exception $e) {
luceneapi_throw_error($e, WATCHDOG_ERROR, 'facetapi_luceneapi');
}
}