protected function SearchApiSolrBackend::setRpt in Search API Solr 4.x
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 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()
Adds rpt spatial features to the search query.
Parameters
\Solarium\QueryType\Select\Query\Query $solarium_query: The Solarium query.
array $rpt_options: The rpt spatial options to add.
\Drupal\search_api\Query\QueryInterface $query: The Search API query.
Throws
\Drupal\search_api\SearchApiException
\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 4308
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, QueryInterface $query) {
// Add location filter.
if (count($rpt_options) > 1) {
throw new SearchApiSolrException('Only one spatial search can be handled per query.');
}
$field_names = $this
->getSolrFieldNames($query
->getIndex());
$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']);
}