Newer Version Available

This content describes an older version of this product. View Latest

Search for a String

Use the Search resource to execute a SOSL search or use the Parameterized Search resource to execute a simple RESTful search without SOSL.

Example SOSL Search Using the GET Method

The following example executes a SOSL search for Acme. The search string in this example must be URL-encoded.
Example usage
1curl https://na1.salesforce.com/services/data/v35.0/search/?q=FIND+%7BAcme%7D -H "Authorization: Bearer token"
Example request body
None required
Example response body
1[ 
2    {
3        "attributes" : 
4         {
5            "type" : "Account",  
6            "url" : "/services/data/v35.0/sobjects/Account/001D000000IqhSLIAZ"
7        },
8        "Id" : "001D000000IqhSLIAZ",
9        "Name" : "Acme"
10    }, 
11    {
12        "attributes" :
13        {  
14            "type" : "Account",  
15            "url" : "/services/data/v35.0/sobjects/Account/001D000000IomazIAB"
16        },
17        "Id" : "001D000000IomazIAB",
18        "Name" : "Acme Import Company"
19    }
20]

Example Parameterized Search Using the GET Method

The following example executes a parameterized search for Acme. The search string in this example must be URL-encoded.
Example usages
Global search for all results containing Acme
1curl https://na1.salesforce.com/services/data/v36.0/parameterizedSearch/?q=Acme
Account search for results containing Acme, returning the id and name fields
1curl https://na1.salesforce.com/services/data/v36.0/parameterizedSearch/?q=Acme&sobject=Account&Account.fields=id,name&Account.limit=10
Example request body
None required
Example response body
1[ 
2    {
3        "attributes" : 
4         {
5            "type" : "Account",  
6            "url" : "/services/data/v36.0/sobjects/Account/001D000000IqhSLIAZ"
7        },
8        "Id" : "001D000000IqhSLIAZ"
9    }, 
10    {
11        "attributes" :
12        {  
13            "type" : "Account",  
14            "url" : "/services/data/v36.0/sobjects/Account/001D000000IomazIAB"
15        },
16        "Id" : "001D000000IomazIAB"
17    }
18]

Example Parameterized Search Using the POST Method

Execute a parameterized search using the POST method to access all search features available.
Example usage
1curl https://na1.salesforce.com/services/data/v36.0/parameterizedSearch "Authorization: Bearer token-H "Content-Type: application/json” -d "@search.json”
Example request body
None required
Example JSON file
1{
2    "q":"Smith",
3    "fields" : ["id", "firstName", "lastName"],
4    "sobjects":[{"fields":["id", "NumberOfEmployees"],
5	          "name": "Account", 
6	          "limit":20},
7	         {"name": "Contact"}],
8    "in":"ALL",
9    "overallLimit":100,
10    "defaultLimit":10
11}
Example response body
1[ {
2  "attributes" : {
3    "type" : "Contact",
4    "url" : "/services/data/v36.0/sobjects/Contact/003xx000004TraiAAC"
5  },
6  "Id" : "003xx000004TraiAAC",
7  "FirstName" : "Smith",
8  "LastName" : "Johnson"
9}, { 
10  "attributes" : {
11    "type" : "Account",
12    "url" : "/services/data/v36.0/sobjects/Account/001xx000003DHXnAAO"
13  },
14  "Id" : "001xx000003DHXnAAO",
15  "NumberOfEmployees" : 100
16} ]