protected function SolrFieldManager::buildFieldDefinitions in Search API Solr 8.3
Same name and namespace in other branches
- 8.2 src/SolrFieldManager.php \Drupal\search_api_solr\SolrFieldManager::buildFieldDefinitions()
- 4.x src/SolrFieldManager.php \Drupal\search_api_solr\SolrFieldManager::buildFieldDefinitions()
Builds the field definitions for a Solr server.
Initially the defintions will be built from a the response of a luke query handler directly from Solr. But once added to the Drupal config, the definitions will be a mix of the Drupal config and not yet used fields from Solr. This strategy also covers scenarios when the Solr server is temporarily offline or re-indexed and prevents exceptions in Drupal's admin UI.
Parameters
\Drupal\search_api\IndexInterface $index: The index from which we are retrieving field information.
Return value
\Drupal\Core\TypedData\DataDefinitionInterface[] The array of field definitions for the server, keyed by field name.
Throws
\InvalidArgumentException
\Drupal\search_api\SearchApiException
1 call to SolrFieldManager::buildFieldDefinitions()
1 method overrides SolrFieldManager::buildFieldDefinitions()
- SolrMultisiteFieldManager::buildFieldDefinitions in src/
SolrMultisiteFieldManager.php - Builds the field definitions for a multisite index.
File
- src/
SolrFieldManager.php, line 109
Class
- SolrFieldManager
- Manages the discovery of Solr fields.
Namespace
Drupal\search_api_solrCode
protected function buildFieldDefinitions(IndexInterface $index) {
$solr_fields = $this
->buildFieldDefinitionsFromSolr($index);
$config_fields = $this
->buildFieldDefinitionsFromConfig($index);
$fields = $solr_fields + $config_fields;
/*** @var \Drupal\Core\TypedData\DataDefinitionInterface $field */
foreach ($config_fields as $key => $field) {
// Always use the type as already configured in Drupal previously.
$fields[$key]
->setDataType($field
->getDataType());
}
return $fields;
}