public function SearchApiRpt::execute in Search API Location 8
Adds facet info to the query using the backend native query object.
Overrides QueryTypeInterface::execute
File
- modules/
facets_map_widget/ src/ Plugin/ facets/ query_type/ SearchApiRpt.php, line 25
Class
- SearchApiRpt
- Provides support for location facets within the Search API scope.
Namespace
Drupal\facets_map_widget\Plugin\facets\query_typeCode
public function execute() {
$query = $this->query;
$field_identifier = $this->facet
->getFieldIdentifier();
// Set the options for the actual query.
$options =& $query
->getOptions();
$options['search_api_facets'][$field_identifier] = [
'field' => $field_identifier,
'limit' => $this->facet
->getHardLimit(),
'operator' => $this->facet
->getQueryOperator(),
'min_count' => $this->facet
->getMinCount(),
'missing' => FALSE,
];
// Bounding box coordinates which dynamically updated by panning or zooming
// the map. By default its value is bounding box coordinates of whole world.
$geom_value = '["-180 -90" TO "180 90"]';
if (!empty($this->facet
->getActiveItems())) {
$geom_value = reset($this->facet
->getActiveItems());
$geom_value = str_replace([
'(geom:',
')',
], [
'',
'',
], $geom_value);
}
$options['search_api_rpt'][$field_identifier] = [
'field' => $field_identifier,
'geom' => $geom_value,
'gridLevel' => '2',
'maxCells' => '35554432',
'distErrPct' => '',
'distErr' => '',
'format' => 'ints2D',
];
}