You are here

protected function SearchApiSolrBackend::applySearchWorkarounds in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::applySearchWorkarounds()
  2. 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::applySearchWorkarounds()
  3. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::applySearchWorkarounds()

Apply workarounds for special Solr versions before searching.

Parameters

\Solarium\QueryType\Select\Query\Query $solarium_query: The Solarium select query object.

\Drupal\search_api\Query\QueryInterface $query: The \Drupal\search_api\Query\Query object representing the executed search query.

1 call to SearchApiSolrBackend::applySearchWorkarounds()
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 1070

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function applySearchWorkarounds(Query $solarium_query, QueryInterface $query) {

  // Do not modify 'Server index status' queries.
  // @see https://www.drupal.org/node/2668852
  if ($query
    ->hasTag('server_index_status')) {
    return;
  }
  $connector = $this
    ->getSolrConnector();
  $schema_version = $connector
    ->getSchemaVersion();
  $solr_version = $connector
    ->getSolrVersion();

  // Schema versions before 4.4 set the default query operator to 'AND'. But
  // incompatibilities since Solr 5.5.0 required a new query builder that
  // bases on 'OR'.
  // @see https://www.drupal.org/node/2724117
  if (version_compare($schema_version, '4.4', '<')) {
    $params = $solarium_query
      ->getParams();
    if (!isset($params['q.op'])) {
      $solarium_query
        ->addParam('q.op', 'OR');
    }
  }
}