You are here

protected function AbstractSearchApiSolrMultilingualBackend::getAutocompleteFields in Search API Solr 8.2

Get the fields to search for autocomplete terms.

Parameters

\Drupal\search_api\Query\QueryInterface $query: A query representing the completed user input so far.

Return value

array

Overrides SearchApiSolrBackend::getAutocompleteFields

File

src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php, line 608

Class

AbstractSearchApiSolrMultilingualBackend
A abstract base class for all multilingual Solr Search API backends.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function getAutocompleteFields(QueryInterface $query) {
  $fl = [];
  $solr_field_names = $this
    ->getSolrFieldNames($query
    ->getIndex());
  foreach ($query
    ->getLanguages() as $langcode) {

    // We explicit allow to get terms from twm_suggest. Therefore we call
    // BackendPluginBase::getQueryFulltextFields() to not filter twm_suggest.
    $fulltext_fields = BackendPluginBase::getQueryFulltextFields($query);
    $language_specific_fulltext_fields = $this
      ->getLanguageSpecificSolrFieldNames($langcode, $solr_field_names, $query
      ->getIndex());
    foreach ($fulltext_fields as $fulltext_field) {
      $fl[] = $language_specific_fulltext_fields[$fulltext_field];
    }
  }
  return array_unique($fl);
}