protected function SearchApiSolrBackend::getAutocompleteSuggesterSuggestions in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getAutocompleteSuggesterSuggestions()
- 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getAutocompleteSuggesterSuggestions()
Get the term suggestions from the autocomplete query result.
Parameters
\Solarium\Core\Query\Result\ResultInterface $result: An autocomplete query result.
\Drupal\search_api_autocomplete\Suggestion\SuggestionFactory $suggestion_factory: The suggestion factory.
Return value
\Drupal\search_api_autocomplete\Suggestion\SuggestionInterface[] An array of suggestions.
1 call to SearchApiSolrBackend::getAutocompleteSuggesterSuggestions()
- SearchApiSolrBackend::getSuggesterSuggestions in src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php
File
- src/
Plugin/ search_api/ backend/ SearchApiSolrBackend.php, line 3862
Class
- SearchApiSolrBackend
- Apache Solr backend for search api.
Namespace
Drupal\search_api_solr\Plugin\search_api\backendCode
protected function getAutocompleteSuggesterSuggestions(ResultInterface $result, SuggestionFactory $suggestion_factory) {
$suggestions = [];
if ($phrases_result = $result
->getComponent(ComponentAwareQueryInterface::COMPONENT_SUGGESTER)) {
/** @var \Solarium\Component\Result\Suggester\Result $phrases_result */
$dictionaries = array_keys($phrases_result
->getResults());
foreach ($phrases_result
->getAll() as $dictionary_index => $phrases) {
/** @var \Solarium\QueryType\Suggester\Result\Term $phrases */
foreach ($phrases
->getSuggestions() as $phrase) {
$suggestion = $suggestion_factory
->createFromSuggestedKeys($phrase['term']);
if (method_exists($suggestion, 'setDictionary')) {
$suggestion
->setDictionary($dictionaries[$dictionary_index]);
}
$suggestions[] = $suggestion;
}
}
}
return $suggestions;
}