protected function SearchApiSolrBackend::setRpt in Search API Solr 8
Same name and namespace in other branches
- 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setRpt()
- 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setRpt()
- 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setRpt()
Adds rpt spatial features to the search query.
Parameters
\Solarium\QueryType\Select\Query\Query $solarium_query: The solr query.
array $rpt_options: The rpt spatial options to add.
array $field_names: The field names, to add the rpt spatial options for.
Throws
\Drupal\search_api_solr\SearchApiSolrException Thrown when more than one rpt spatial searches are added.
1 call to SearchApiSolrBackend::setRpt()
- SearchApiSolrBackend::search in src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php - Options on $query prefixed by 'solr_param_' will be passed natively to Solr as query parameter without the prefix. For example you can set the "Minimum Should Match" parameter 'mm' to '75%' like this:
File
- src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php, line 2679
Class
- SearchApiSolrBackend
- Apache Solr backend for search api.
Namespace
Drupal\search_api_solr\Plugin\search_api\backendCode
protected function setRpt(Query $solarium_query, array $rpt_options, $field_names = array()) {
// Add location filter
if (count($rpt_options) > 1) {
throw new SearchApiSolrException('Only one spatial search can be handled per query.');
}
$rpt = reset($rpt_options);
$solr_field = $field_names[$rpt['field']];
$rpt['geom'] = isset($rpt['geom']) ? $rpt['geom'] : '["-180 -90" TO "180 90"]';
// Add location filter
$solarium_query
->createFilterQuery($solr_field)
->setQuery($solr_field . ':' . $rpt['geom']);
// Add Solr Query params
$solarium_query
->addParam('facet', 'on');
$solarium_query
->addParam('facet.heatmap', $solr_field);
$solarium_query
->addParam('facet.heatmap.geom', $rpt['geom']);
$solarium_query
->addParam('facet.heatmap.format', $rpt['format']);
$solarium_query
->addParam('facet.heatmap.maxCells', $rpt['maxCells']);
$solarium_query
->addParam('facet.heatmap.gridLevel', $rpt['gridLevel']);
}