You are here

public function SearchApiSolrBackend::getSchemaLanguageStatistics in Search API Solr 8.3

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

Gets schema language statistics for the multilingual Solr server.

Return value

array Stats as associative array keyed by language IDs and a boolean value to indicate if corresponding field types are existing on the server's current schema.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\search_api\SearchApiException

\Drupal\search_api_solr\SearchApiSolrException

Overrides SolrBackendInterface::getSchemaLanguageStatistics

1 call to SearchApiSolrBackend::getSchemaLanguageStatistics()
SearchApiSolrBackend::setSpellcheck in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Adds spellcheck features to the search query.

File

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

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function getSchemaLanguageStatistics() {

  // @todo iterate over all indexes in case of cloud?
  $available = $this
    ->getSolrConnector()
    ->pingCore();
  $stats = [];
  foreach (\Drupal::languageManager()
    ->getLanguages() as $language) {
    $solr_field_type_name = 'text' . '_' . $language
      ->getId();
    $stats[$language
      ->getId()] = $available ? $this
      ->isPartOfSchema('fieldTypes', $solr_field_type_name) : FALSE;
  }
  return $stats;
}