You are here

public function SearchApiSolrBackend::getCollectionEndpoint in Search API Solr 4.x

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::getCollectionEndpoint()

Returns the endpoint to use for the index.

In case of Solr Cloud an index might use a different Solr collection.

Parameters

\Drupal\search_api\IndexInterface $index:

Return value

\Solarium\Core\Client\Endpoint

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\search_api\SearchApiException

Overrides SolrBackendInterface::getCollectionEndpoint

12 calls to SearchApiSolrBackend::getCollectionEndpoint()
SearchApiSolrBackend::deleteAllIndexItems in src/Plugin/search_api/backend/SearchApiSolrBackend.php
SearchApiSolrBackend::deleteItems in src/Plugin/search_api/backend/SearchApiSolrBackend.php
SearchApiSolrBackend::executeGraphStreamingExpression in src/Plugin/search_api/backend/SearchApiSolrBackend.php
SearchApiSolrBackend::executeStreamingExpression in src/Plugin/search_api/backend/SearchApiSolrBackend.php
SearchApiSolrBackend::getAutocompleteSuggestions in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Implements autocomplete compatible to AutocompleteBackendInterface.

... See full list

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 1311

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function getCollectionEndpoint(IndexInterface $index) {
  $connector = $this
    ->getSolrConnector();
  if ($this->solrConnector
    ->isCloud()) {

    // Using the index_id as endpoint name leads to collisions in a multisite
    // setup. Using the index filter query string instead is a good
    // workaround.
    $endpoint_name = $this
      ->getIndexFilterQueryString($index);
    try {
      return $this->solrConnector
        ->getEndpoint($endpoint_name);
    } catch (OutOfBoundsException $e) {
      $additional_config = [];
      if ($settings = Utility::getIndexSolrSettings($index)) {
        if ($settings['advanced']['collection']) {
          $additional_config['core'] = $settings['advanced']['collection'];
        }
      }
      return $this->solrConnector
        ->createEndpoint($endpoint_name, $additional_config);
    }
  }
  return $connector
    ->getEndpoint();
}