---
schema_version: "1"
id: 724d364ee15f544ad0406e2a4deb08bb08795a3b16300ef5e8a60d5e7c961f1b
title: SearchResult Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Search_SearchResult.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Search_SearchResult.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b86c96e223da9501c025970ec9d90c01b9bd02ce64629c990bce376c7fd86576
description: A wrapper object that contains an sObject and search metadata.Returns an sObject from a SearchResult object.Returns a snippet from a Case, Feed, or Knowledge Article SearchResult object based on the specified field name.Returns a snippet from a SearchResult object based on the default field.
---
# SearchResult Class

A wrapper object that contains an sObject and search metadata.

## Namespace

[Search](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Search.htm#apex_namespace_Search "The Search namespace provides classes for getting search results and suggestion results.")

## SearchResult Methods

The following are methods for SearchResult.

- **[getSObject()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Search_SearchResult.htm#apex_Search_SearchResult_getSObject)**  
    Returns an sObject from a SearchResult object.
- **[getSnippet(fieldName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Search_SearchResult.htm#apex_Search_SearchResult_getSnippet)**  
    Returns a snippet from a Case, Feed, or Knowledge Article SearchResult object based on the specified field name.
- **[getSnippet()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Search_SearchResult.htm#apex_Search_SearchResult_getSnippet_2)**  
    Returns a snippet from a SearchResult object based on the default field.

### getSObject()

Returns an sObject from a SearchResult object.

#### Signature

public SObject getSObject()

#### Return Value

Type: [SObject](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_sobject.htm#apex_methods_system_sobject "Contains methods for the sObject data type.")

#### See Also

- [find(searchQuery)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_search.htm#apex_System_Search_find "Performs a dynamic SOSL query that can include the SOSL WITH SNIPPET clause. Snippets provide more context for users in Salesforce Knowledge article search results.")
- [_Apex Developer Guide_: Dynamic SOSL](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_dynamic_sosl.htm "Apex Developer Guide: Dynamic SOSL - HTML (New Window)")

### getSnippet(fieldName)

Returns a snippet from a Case, Feed, or Knowledge Article SearchResult object based on the specified field name.

#### Signature

public String getSnippet(String fieldName)

#### Parameters

- **fieldName**: Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.") The field name to use for creating the snippet. Valid values: Case.Casenumber, FeedPost.Title, KnowledgeArticleVersion.Title

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

#### See Also

- [find(searchQuery)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_search.htm#apex_System_Search_find "Performs a dynamic SOSL query that can include the SOSL WITH SNIPPET clause. Snippets provide more context for users in Salesforce Knowledge article search results.")
- [_Apex Developer Guide_: Dynamic SOSL](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_dynamic_sosl.htm "Apex Developer Guide: Dynamic SOSL - HTML (New Window)")

### getSnippet()

Returns a snippet from a SearchResult object based on the default field.

#### Signature

public String getSnippet()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

#### See Also

- [find(searchQuery)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_search.htm#apex_System_Search_find "Performs a dynamic SOSL query that can include the SOSL WITH SNIPPET clause. Snippets provide more context for users in Salesforce Knowledge article search results.")
- [_Apex Developer Guide_: Dynamic SOSL](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_dynamic_sosl.htm "Apex Developer Guide: Dynamic SOSL - HTML (New Window)")