You are here

public function StreamingExpressionBuilder::_select_copied_field in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Utility/StreamingExpressionBuilder.php \Drupal\search_api_solr\Utility\StreamingExpressionBuilder::_select_copied_field()
  2. 8.2 src/Utility/StreamingExpressionBuilder.php \Drupal\search_api_solr\Utility\StreamingExpressionBuilder::_select_copied_field()

Copy a field's value to a different field within select().

Parameters

string $search_api_field_name_source: The Search API field name to copy.

string $search_api_field_name_target: The target field name.

string $language_id: (optional) The language ID. Defaults to "und".

Return value

string The expression as string.

File

src/Utility/StreamingExpressionBuilder.php, line 462

Class

StreamingExpressionBuilder
Provides methods for creating streaming expressions targeting a given index.

Namespace

Drupal\search_api_solr\Utility

Code

public function _select_copied_field(string $search_api_field_name_source, string $search_api_field_name_target, string $language_id = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
  if (version_compare($this->connector
    ->getSolrVersion(), '8.4.1', '>=')) {
    return $this
      ->concat($this
      ->_field($search_api_field_name_source, $language_id) . ',delim=","') . ' as ' . $this
      ->_field($search_api_field_name_target, $language_id);
  }
  return $this
    ->concat('fields="' . $this
    ->_field($search_api_field_name_source, $language_id) . '"', 'delim=","', 'as="' . $this
    ->_field($search_api_field_name_target, $language_id) . '"');
}