You are here

protected function SolrFieldType::getCollatedField in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Entity/SolrFieldType.php \Drupal\search_api_solr\Entity\SolrFieldType::getCollatedField()

Returns the collated field definition.

Parameters

int|null $solr_major_version:

Return value

array|null The array containing the collated field definition or null if is not configured for this field type.

1 call to SolrFieldType::getCollatedField()
SolrFieldType::getDynamicFields in src/Entity/SolrFieldType.php
Gets a list of dynamic Solr fields that will use this Solr Field Type.

File

src/Entity/SolrFieldType.php, line 524

Class

SolrFieldType
Defines the SolrFieldType entity.

Namespace

Drupal\search_api_solr\Entity

Code

protected function getCollatedField(?int $solr_major_version = NULL) {
  $collated_field = NULL;

  // Solr 3 and 4 need the sort field to be indexed and no docValues.
  if ($this->collated_field_type) {
    $collated_field = [
      'name' => SearchApiSolrUtility::encodeSolrName('sort' . SolrBackendInterface::SEARCH_API_SOLR_LANGUAGE_SEPARATOR . $this->field_type_language_code) . '_*',
      'type' => $this->collated_field_type['name'],
      'stored' => FALSE,
      'indexed' => version_compare($solr_major_version, '5', '<'),
    ];
    if (version_compare($solr_major_version, '5', '>=')) {
      $collated_field['docValues'] = TRUE;
    }
  }
  return $collated_field;
}