Newer Version Available
Search for a String
Use the Search
resource to execute a SOSL
search. Use the HTTP GET method to search for a simple string. Use the HTTP POST method
to search for a more complex string using a JSON file, for a more visual
hierarchy.
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 }, 10 { 11 "attributes" : 12 { 13 "type" : "Account", 14 "url" : "/services/data/v35.0/sobjects/Account/001D000000IomazIAB" 15 }, 16 "Id" : "001D000000IomazIAB" 17 } 18]
Example Simple Search Using the GET Method (Beta)
The following example
executes a search for test. The search string in
this example must be URL-encoded.
- Example usage
-
1curl https://na1.salesforce.com/services/data/v35.0/search/?qs=Acme&fields=id,name, 2email,title&sObject=Account&sObject=Contact&sObject=Lead&Account.fields=id,name,numberofemployees&Account. 3where=numberofemployees<100&overallLimit=300&defaultLimit=100&Account.limit=50 - 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 }, 10 { 11 "attributes" : 12 { 13 "type" : "Account", 14 "url" : "/services/data/v35.0/sobjects/Account/001D000000IomazIAB" 15 }, 16 "Id" : "001D000000IomazIAB" 17 } 18]
Example Search Using the POST Method (Beta)
Execute a search using
the POST method to access all search features available.
- Example usage
-
1curl https://na1.salesforce.com/services/data/v35.0/search "Authorization: Bearer token-H "Content-Type: application/json” -d "@search.json” - Example request body
- None required
- Example JSON file
-
1{ 2"qs”:”Acme”, 3"fields” : ["id”, "firstName”, "lastName”], 4"sobjects”:[{”fields”:[”id”, "name”], 5 "name”: "Account”, 6 "where”: "DISTANCE(My_Location_Field__c,GEOLOCATION(37,122),'mi') < 100”, 7 "orderBy”: {"fields”: "name” 8 "order”: "ASC”, 9 "whereAreNulls”: "last” 10 }, 11 "limit”:20 12 }, 13 14 {"name”: "Contact”} 15 ], 16"in":"ALL", 17"overallLimit":100, 18"defaultLimit”:10 19"updateViewStat": true, 20"updateTracking": true, 21} - 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 }, 10 { 11 "attributes" : 12 { 13 "type" : "Contact", 14 "url" : "/services/data/v35.0/sobjects/Contact/003000000000000" 15 }, 16 "Id" : "003000000000000" 17 } 18]