function hook_search_api_solr_query_alter in Search API Solr 8
Same name and namespace in other branches
- 8.3 search_api_solr.api.php \hook_search_api_solr_query_alter()
- 8.2 search_api_solr.api.php \hook_search_api_solr_query_alter()
- 7 search_api_solr.api.php \hook_search_api_solr_query_alter()
- 4.x search_api_solr.api.php \hook_search_api_solr_query_alter()
Lets modules alter the Solarium select query before executing it.
Parameters
\Solarium\Core\Query\QueryInterface $solarium_query: The Solarium query object, as generated from the Search API query.
\Drupal\search_api\Query\QueryInterface $query: The Search API query object representing the executed search query.
1 invocation of hook_search_api_solr_query_alter()
- 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
- ./
search_api_solr.api.php, line 21 - Hooks provided by the Search API Solr search module.
Code
function hook_search_api_solr_query_alter(\Solarium\Core\Query\QueryInterface $solarium_query, \Drupal\search_api\Query\QueryInterface $query) {
if ($query
->getOption('foobar')) {
// If the Search API query has a 'foobar' option, remove all sorting options
// from the Solarium query.
$solarium_query
->clearSorts();
}
}