You are here

protected function SearchApiSolrBackend::setAutocompleteSuggesterQuery in Search API Solr 8.2

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::setAutocompleteSuggesterQuery()
  2. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setAutocompleteSuggesterQuery()

Set the suggester parameters for the solarium autocomplete query.

Parameters

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

AutocompleteQuery $solarium_query: An autocomplete solarium query.

string $user_input: The user input.

array $options: 'dictionary' as string, 'context_filter_tags' as array of strings.

2 calls to SearchApiSolrBackend::setAutocompleteSuggesterQuery()
AbstractSearchApiSolrMultilingualBackend::setAutocompleteSuggesterQuery in src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php
Set the suggester parameters for the solarium autocomplete query.
SearchApiSolrBackend::getSuggesterSuggestions in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Autocompletion suggestions for some user input using Suggester component.
1 method overrides SearchApiSolrBackend::setAutocompleteSuggesterQuery()
AbstractSearchApiSolrMultilingualBackend::setAutocompleteSuggesterQuery in src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php
Set the suggester parameters for the solarium autocomplete query.

File

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

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function setAutocompleteSuggesterQuery(QueryInterface $query, AutocompleteQuery $solarium_query, $user_input, $options = []) {
  $suggester_component = $solarium_query
    ->getSuggester();
  $suggester_component
    ->setQuery($user_input);
  $suggester_component
    ->setDictionary(!empty($options['dictionary']) ? $options['dictionary'] : 'und');
  if (!empty($options['context_filter_tags'])) {
    $suggester_component
      ->setContextFilterQuery(Utility::buildSuggesterContextFilterQuery($options['context_filter_tags']));
  }
  $suggester_component
    ->setCount($query
    ->getOption('limit', 10));

  // The search_api_autocomplete module highlights by itself.
  $solarium_query
    ->addParam('suggest.highlight', FALSE);
}