Options that narrow record and article suggestion results returned
from a call to System.Search.suggest(String, String,
Search.SuggestionOption).
Namespace
SuggestionOption Methods
The following are methods for SuggestionOption.
setFilter(knowledgeSuggestionFilter)
Set filters that narrow Salesforce Knowledge article results in a
call to System.Search.suggest(String, String,
Search.SuggestionOption).
Signature
public void setFilter(Search.KnowledegeSuggestionFilter knowledgeSuggestionFilter)
Parameters
- knowledgeSuggestionFilter: Type: KnowledgeSuggestionFilter An object containing filters that narrow the search results.
Return Value
Type: void
Usage
Search.KnowledgeSuggestionFilter filters = new Search.KnowledgeSuggestionFilter(); filters.setLanguage('en_US'); filters.setPublishStatus('Online'); filters.setChannel('app'); Search.SuggestionOption options = new Search.SuggestionOption(); options.setFilter(filters); Search.SuggestionResults suggestionResults = Search.suggest('all', 'KnowledgeArticleVersion', options); for (Search.SuggestionResult searchResult : suggestionResults.getSuggestionResults()) { KnowledgeArticleVersion article = (KnowledgeArticleVersion)searchResult.getSObject(); System.debug(article.title); }
setLimit(limit)
Signature
public void setLimit(Integer limit)
Parameters
- limit: Type: Integer The maximum number of record or article suggestions to retrieve.
Return Value
Type: void
Usage
By default, the System.Search.suggest(String, String,
Search.SuggestionOption) method returns the 5 most relevant results. However, if
your query is broad, it could match more than 5 results. If
Search.SuggestionResults.hasMoreResults() returns true, there are more than 5 results. To retrieve them, call setLimit(Integer) to increase the number of suggestions
results.
Search.SuggestionOption option = new Search.SuggestionOption(); option.setLimit(10); Search.suggest('my query', 'mySObjectType', option);