protected function SearchApiElasticsearchBackend::addFacetOptions in Elasticsearch Connector 8
Same name and namespace in other branches
- 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::addFacetOptions()
- 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::addFacetOptions()
- 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::addFacetOptions()
- 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::addFacetOptions()
Helper function that add options and return facet.
1 call to SearchApiElasticsearchBackend::addFacetOptions()
- SearchApiElasticsearchBackend::addSearchFacets in src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php - Helper function build facets in search.
File
- src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php, line 1229 - Contains the SearchApiElasticsearchBackend object.
Class
- SearchApiElasticsearchBackend
- Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )
Namespace
Drupal\elasticsearch_connector\Plugin\search_api\backendCode
protected function addFacetOptions(&$facet, QueryInterface $query, $facet_info) {
$facet_limit = $this
->getFacetLimit($facet_info);
$facet_search_filter = $this
->getFacetSearchFilter($query, $facet_info);
// Set the field.
$facet[$facet_info['facet_type']]['field'] = $facet_info['field'];
// OR facet. We remove filters affecting the assiociated field.
// TODO: distinguish between normal filters and facet filters.
// See http://drupal.org/node/1390598.
// Filter the facet.
if (!empty($facet_search_filter)) {
$facet['facet_filter'] = $facet_search_filter;
}
// Limit the number of returned entries.
if ($facet_limit > 0 && $facet_info['facet_type'] == 'terms') {
$facet[$facet_info['facet_type']]['size'] = $facet_limit;
}
return $facet;
}