You are here

protected function SearchApiElasticsearchElastica::buildSpellcheckQuery in Search API Elasticsearch 7

buildSpellcheckQuery

@access protected

Parameters

SearchApiQueryInterface $query:

Return value

void

File

modules/elastica/includes/SearchApiElasticsearchElastica.inc, line 1018
Provides Elastica client for Search API Elasticsearch.

Class

SearchApiElasticsearchElastica
Search API Elasticsearch Elastica service class.

Code

protected function buildSpellcheckQuery(SearchApiQueryInterface $query) {
  $suggest = new \Elastica\Suggest();
  $phrase = new \Elastica\Suggest\Phrase('suggest1', 'text');
  $phrase
    ->setText($this
    ->flattenKeys($this
    ->getKeys()));
  $phrase
    ->setHighlight("<suggest>", "</suggest>")
    ->setStupidBackoffSmoothing();
  $phrase
    ->addCandidateGenerator(new \Elastica\Suggest\CandidateGenerator\DirectGenerator("text"));
  $suggest
    ->addSuggestion($phrase);
  return $suggest;
}