public function SearchApiSolrBackend::getSchemaLanguageStatistics 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::getSchemaLanguageStatistics()
Gets schema language statistics for the multilingual Solr server.
Parameters
\Solarium\Core\Client\Endpoint|null $endpoint: If not set, the statistics for the server's default endpoint will be returned.
Return value
array Stats as associative array keyed by language IDs. The value is the language id of the corresponding field type existing on the server's current schema or FALSE.
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 4557
Class
- SearchApiSolrBackend
- Apache Solr backend for search api.
Namespace
Drupal\search_api_solr\Plugin\search_api\backendCode
public function getSchemaLanguageStatistics(?Endpoint $endpoint = NULL) {
$available = $this
->getSolrConnector()
->pingServer();
$stats = [];
foreach (\Drupal::languageManager()
->getLanguages() as $language) {
$language_id = $language
->getId();
// Convert zk-hans to zk_hans.
$converted_language_id = str_replace('-', '_', $language_id);
$stats[$language_id] = $available ? $this
->isPartOfSchema('fieldTypes', 'text_' . $converted_language_id, $endpoint) ? $converted_language_id : FALSE : FALSE;
if (!$stats[$language_id]) {
// Try language fallback.
$converted_language_id = preg_replace('/-.+$/', '', $language_id);
$stats[$language_id] = $available ? $this
->isPartOfSchema('fieldTypes', 'text_' . $converted_language_id, $endpoint) ? $converted_language_id : FALSE : FALSE;
}
}
return $stats;
}