You are here

protected function SearchApiSolrBackend::getAutocompleteFields in Search API Solr 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getAutocompleteFields()
  2. 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getAutocompleteFields()
  3. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getAutocompleteFields()

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 An array of fulltext field definitions.

Throws

\Drupal\search_api\SearchApiException

1 call to SearchApiSolrBackend::getAutocompleteFields()
SearchApiSolrBackend::setAutocompleteTermQuery in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Set the term parameters for the solarium autocomplete query.

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 3388

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function getAutocompleteFields(QueryInterface $query) {
  $fl = [];
  $language_ids = $query
    ->getLanguages();
  $field_names = $this
    ->getSolrFieldNamesKeyedByLanguage($language_ids, $query
    ->getIndex());

  // We explicit allow to get terms from twm_suggest. Therefore we call
  // parent::getQueryFulltextFields() to not filter twm_suggest.
  foreach (parent::getQueryFulltextFields($query) as $fulltext_field) {
    $fl[] = array_values($field_names[$fulltext_field]);
  }
  return array_unique(array_merge(...$fl));
}