SearchResult

The search() call returns a SearchResult object.

A SearchResult object has these fields.

NameTypeDescription
queryIdstringUnique identifier for the SOSL search.
searchRecordsSearchRecord[]Array of SearchRecord objects, each of which contains an sObject.
searchResultsMetadataSearchResultsMetadataMetadata for SearchRecords.

SearchRecord 

Represents an individual record returned from a search.

NameTypeDescription
recordsObjectThe individual record returned by the search.
searchRecordMetadataSearchRecordMetadataMetadata for searchRecords.
snippetSearchSnippetOn the search results page, shows terms that match the search string, highlighted within the surrounding text.

SearchRecordMetadata 

Metadata for search results at the record level.

NameTypeDescription
searchPromotedbooleanIndicates that an article has been promoted in search results. Admins define promoted search terms by adding promoted terms to knowledge articles. Users who search for these keywords see the article first in search results. Available in API version 42.0 and later.
spellCorrectedbooleanIndicates that a record matches a spell-corrected search term. Appears in the response only when true.

SearchSnippet 

Excerpts shown on search results pages for article, case, feed, and idea searches.

NameTypeDescription
textstringThe excerpt that contains the match for the search term.
wholeFieldsWholeFieldsThe list of highlighted fields.

WholeFields 

Contains the complete text of each field that contains highlighting for terms that match the search query. The highlighted terms are surrounded by <mark> tags.

NameTypeDescription
namestringThe name of the highlighted field.
valuestringThe highlighted text.

SearchResultsMetadata 

Global metadata for the search result.

NameTypeDescription
entityMetadataEntitySearchMetadataSearch results metadata at the object level.

EntitySearchMetadata 

Metadata for search results at the object level.

NameTypeDescription
fieldMetadataFieldLevelSearchMetadataMetadata for search results at the field level.
searchPromotedMetadataEntitySearchPromotionMetadataMetadata for search term promotion at the object level. Available in API version 42.0 and later.
spellCorrectionMetadataEntitySpellCorrectionMetadataMetadata for spelling correction at the object level.
entityNamestringIdentifies the object.

FieldLevelSearchMetadata 

Metadata for search results at the field level.

NameTypeDescription
namestringThe field name.
labelstringThe field label.
typestringThe field type.

EntitySearchPromotionMetadata 

Metadata for search term promotion at the object level. Appears in the response only when at least one article for an object is a promoted result. Available in API version 42.0 and later.

NameTypeDescription
promotedResultCountintCount of promoted article results at the object level.

EntitySpellCorrectionMetadata 

Metadata for spelling correction at the object level. Appears in the response only when at least one record for an object matches a spell-corrected search term.

NameTypeDescription
correctedQuerystringThe spell-corrected search term.
hasNonCorrectedResultsbooleanIf true, indicates that the user has access to at least one record that matches a search term that wasn’t spell-corrected. Each object sometimes returns a different value.

See Also