protected function SearchApiElasticsearchConnector::buildSpellcheckQuery in Elasticsearch Connector 7
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::buildSpellcheckQuery()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::buildSpellcheckQuery()
Handle the spellcheck
Parameters
SearchApiQueryInterface $query:
1 call to SearchApiElasticsearchConnector::buildSpellcheckQuery()
- SearchApiElasticsearchConnector::buildSearchQuery in modules/
elasticsearch_connector_search_api/ service.inc - Helper function build search query().
File
- modules/
elasticsearch_connector_search_api/ service.inc, line 646 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected function buildSpellcheckQuery(SearchApiQueryInterface $query, &$params) {
$options = $query
->getOptions();
$keys = $query
->getOriginalKeys();
if (!empty($options['search_api_spellcheck']) && !empty($keys)) {
$fields = $query
->getFields();
if (!empty($fields)) {
$params['body']['suggest'] = array(
'text' => $query
->getOriginalKeys(),
);
foreach ($fields as $field) {
$params['body']['suggest'][$field . '_spellcheck'] = array(
'phrase' => array(
'field' => $field,
),
);
}
}
}
}