You are here

protected function SearchApiSolrBackend::setAutocompleteTermQuery in Search API Solr 8.3

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

Set the term parameters for the solarium autocomplete query.

Parameters

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

\Drupal\search_api_solr\Solarium\Autocomplete\Query $solarium_query: A Solarium autocomplete query.

string $incomplete_key: The start of another fulltext keyword for the search, which should be completed.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\search_api\SearchApiException

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

File

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

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function setAutocompleteTermQuery(QueryInterface $query, AutocompleteQuery $solarium_query, $incomplete_key) {
  $fl = $this
    ->getAutocompleteFields($query);
  $terms_component = $solarium_query
    ->getTerms();
  $terms_component
    ->setFields($fl);
  $terms_component
    ->setPrefix($incomplete_key);
  $terms_component
    ->setLimit($query
    ->getOption('limit') ?? 10);
}