Spellcheck.php in Search API Solr 4.x
File
src/Plugin/search_api_autocomplete/suggester/Spellcheck.php
View source
<?php
namespace Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\search_api\Plugin\PluginFormTrait;
use Drupal\search_api\Query\QueryInterface;
use Drupal\search_api_autocomplete\SearchInterface;
use Drupal\search_api_autocomplete\Suggester\SuggesterPluginBase;
class Spellcheck extends SuggesterPluginBase implements PluginFormInterface {
use PluginFormTrait;
use BackendTrait;
public static function supportsSearch(SearchInterface $search) {
$backend = static::getBackend($search
->getIndex());
return $backend && version_compare($backend
->getSolrConnector()
->getSolrMajorVersion(), '4', '>=');
}
public function defaultConfiguration() {
return [];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return [];
}
public function getAutocompleteSuggestions(QueryInterface $query, $incomplete_key, $user_input) {
if (!($backend = static::getBackend($this
->getSearch()
->getIndex()))) {
return [];
}
return $backend
->getSpellcheckSuggestions($query, $this
->getSearch(), $incomplete_key, $user_input);
}
}
Classes
Name |
Description |
Spellcheck |
Provides a suggester plugin that retrieves suggestions from the server. |