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://MyDomainName.my.salesforce.com/services/data/v67.0/search/?q=FIND+%7BAcme%7D -H "Authorization: Bearer token"Example request body: None required
Example response body
1{
2 "searchRecords" : [ {
3 "attributes" : {
4 "type" : "Account",
5 "url" : "/services/data/v67.0/sobjects/Account/001D000000IqhSLIAZ"
6 },
7 "Id" : "001D000000IqhSLIAZ",
8 }, {
9 "attributes" : {
10 "type" : "Account",
11 "url" : "/services/data/v67.0/sobjects/Account/001D000000IomazIAB"
12 },
13 "Id" : "001D000000IomazIAB",
14 } ]
15}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 Account search for results containing Acme, returning the id and name fields
1curl https://MyDomainName.my.salesforce.com/services/data/v67.0/parameterizedSearch/?q=Acme -H "Authorization: Bearer token"1curl https://MyDomainName.my.salesforce.com/services/data/v67.0/parameterizedSearch/?q=Acme&sobject=Account&Account.fields=id,name&Account.limit=10 -H "Authorization: Bearer token"Example request body: None required
Example response body
1{
2 "searchRecords" : [ {
3 "attributes" : {
4 "type" : "Account",
5 "url" : "/services/data/v67.0/sobjects/Account/001D000000IqhSLIAZ"
6 },
7 "Id" : "001D000000IqhSLIAZ"
8 }, {
9 "attributes" : {
10 "type" : "Account",
11 "url" : "/services/data/v67.0/sobjects/Account/001D000000IomazIAB"
12 },
13 "Id" : "001D000000IomazIAB"
14 } ]
15}Example response body with metadata parameter
1{
2 "searchRecords" : [ {
3 "attributes" : {
4 "type" : "Account",
5 "url" : "/services/data/v67.0/sobjects/Account/001D000000IqhSLIAZ"
6 },
7 "Id" : "001D000000IqhSLIAZ",
8 }, {
9 "attributes" : {
10 "type" : "Account",
11 "url" : "/services/data/v67.0/sobjects/Account/001D000000IomazIAB"
12 },
13 "Id" : "001D000000IomazIAB",
14 } ],
15 "metadata" : {
16 "entityetadata" : [ {
17 "entityName" : "Account",
18 "fieldMetadata" : [ {
19
20 "name" : "Name",
21 "label" : "Account Name"
22 } ]
23 } ]
24 }
25}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://MyDomainName.my.salesforce.com/services/data/v67.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 "searchRecords" : [ {
3 "attributes" : {
4 "type" : "Contact",
5 "url" : "/services/data/v67.0/sobjects/Contact/003xx000004TraiAAC"
6 },
7 "Id" : "003xx000004TraiAAC",
8 "FirstName" : "Smith",
9 "LastName" : "Johnson"
10 }, {
11 "attributes" : {
12 "type" : "Account",
13 "url" : "/services/data/v67.0/sobjects/Account/001xx000003DHXnAAO"
14 },
15 "Id" : "001xx000003DHXnAAO",
16 "NumberOfEmployees" : 100
17 } ]
18}