You are here

function SearchApiElasticsearchElasticaSpellcheck::__construct in Search API Elasticsearch 7

File

modules/elastica/includes/SearchApiElasticsearchElasticaSpellcheck.inc, line 5

Class

SearchApiElasticsearchElasticaSpellcheck

Code

function __construct($response) {
  $suggestions = $response
    ->getSuggests();
  foreach ($suggestions as $suggestion_group) {
    foreach ($suggestion_group as $suggestion_set) {
      $original = $suggestion_set['text'];
      foreach ($suggestion_set['options'] as $suggestion) {
        $this
          ->addSuggestion(new SearchApiSpellcheckSuggestion($original, $suggestion['text']));
      }
    }
  }
}