You are here

protected function SearchApiSolrBackend::getAutocompleteFields in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 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.

\Drupal\search_api_autocomplete\SearchInterface $search: An object containing details about the search the user is on, and settings for the autocompletion. See the class documentation for details. Especially $search->options should be checked for settings, like whether to try and estimate result counts for returned suggestions.

Return value

array

1 call to SearchApiSolrBackend::getAutocompleteFields()
SearchApiSolrBackend::getAutocompleteSuggestions in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Implements autocomplete compatible to AutocompleteBackendInterface.

File

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

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function getAutocompleteFields(QueryInterface $query, SearchInterface $search) {
  $fl = [];
  $solr_field_names = $this
    ->getSolrFieldNames($query
    ->getIndex());
  $fulltext_fields = $search
    ->getOption('fields') ? $search
    ->getOption('fields') : $this
    ->getQueryFulltextFields($query);
  foreach ($fulltext_fields as $fulltext_field) {
    $fl[] = 'terms_' . $solr_field_names[$fulltext_field];
  }
  return $fl;
}