Newer Version Available
Search for Records Suggested by Autocomplete and Instant Results
Returns a list of suggested records whose names match the
user’s search string. The suggestions resource provides autocomplete results and instant
results for users to navigate directly to likely relevant records, before performing a full
search.
Syntax
- URI
- vXX.X/search/suggestions?q=search_string&sobject=object_types
- Available since release
- 32.0
- Formats
- JSON, XML
- HTTP methods
- GET
- Authentication
- Authorization: Bearer token
- Request body
- None required
- Request parameters
-
Usage
The suggestions resource returns records when the record’s name
field includes the exact text in the search string. The last term in the search string can
match the beginning of a word. Records that contain the search string within a word aren’t
considered a match.
Example
The text string national u is treated as national
u* and returns “National Utility”, “National Urban Company”, and “First National
University”.
Suggested Records Response
The suggestions resource returns display-ready
data about likely relevant records that the user can access.
A relevance algorithm determines the order of results.
Each suggested record in the results contains these elements:
| Element | Description |
|---|---|
| Attributes | The record’s object type and the URL for accessing the record. Also includes the requested lookup fields’ values. For example, if you requested fields=Id,Name, the result would include the ID and name. |
| Name (or Title) | The record’s Name field. In the absence of a standard Name field, the Title
field is used for these objects:
|
| Id | The record’s unique identifier. |
Example JSON Response Body
1{
2 "autoSuggestResults" : [ {
3 "attributes" : {
4 "type" : "Account",
5 "url" : "/services/data/v50.0/sobjects/Account/001xx000003DH6WAAW"
6 },
7 "Id" : "001xx000003DH6WAAW",
8 "Name" : "National Utility Service"
9 }, {
10 {
11 "attributes" : {
12 "type" : "Account",
13 "url" : "/services/data/v50.0/sobjects/Account/001xx000003DHJ4AAO"
14 },
15 "Id" : "001xx000003DHJ4AAO",
16 "Name" : "National Utility Service"
17 }, {
18 {
19 "attributes" : {
20 "type" : "Account",
21 "url" : "/services/data/v50.0/sobjects/Account/001xx000003DHscAAG"
22 },
23 "Id" : "001xx000003DHscAAG",
24 "Name" : "National Urban Technology Center"
25 } ],
26 "hasMoreResults" : false,
27 "meta" : {
28 "nameFields" : [ {
29 "entityApiName" : "Account",
30 "fieldApiName" : "Name"
31 } ],
32 "secondaryFields" : [ ]
33 }
34}Example JSON Response Body for a Multiple Object Request
1{
2 "autoSuggestResults" : [ {
3 "attributes" : {
4 "type" : "Account",
5 "url" : "/services/data/v50.0/sobjects/Account/001xx000003DMEKAA4"
6 },
7 "Id" : "001xx000003DMEKAA4"
8 "Name" : "Joe Doe Printing"
9 }, {
10 {
11 "attributes" : {
12 "type" : "Account",
13 "url" : "/services/data/v50.0/sobjects/Account/001xx000003DLjvAAG"
14 },
15 "Id" : "001xx000003DLjvAAGO"
16 "Name" : "Joe Doe Plumbing"
17 }, {
18 {
19 "attributes" : {
20 "type" : "Contact",
21 "url" : "/services/data/v50.0/sobjects/Contact/003xx000004U9Y9AAK"
22 },
23 "Id" : "003xx000004U9Y9AAK"
24 "Name" : "John Doe"
25 } ],
26 "hasMoreResults" : false,
27 "meta" : {
28 "nameFields" : [ {
29 "entityApiName" : "Account",
30 "fieldApiName" : "Name"
31 }, {
32 "entityApiName" : "Contact",
33 "fieldApiName" : "Name"
34 } ],
35 "secondaryFields" : [ ]
36 }
37}Example XML Response Body
1<?xml version=”1.0” encoding=”UTF-8”?
2<suggestions>
3 <autoSuggestResults type="Account" url="/services/data/v50.0/sobjects/Account/001xx000003DH6WAAW">
4 <Id>001xx000003DH6WAAW</Id>
5 <Name>National Utility Service</Name>
6 </autoSuggestResults>
7 <autoSuggestResults type="Account" url="/services/data/v50.0/sobjects/Account/001xx000003DHJ4AAO">
8 <Id>001xx000003DHJ4AAO</Id>
9 <Name>National Utility Service</Name>
10 </autoSuggestResults>
11 <autoSuggestResults type="Account" url="/services/data/v50.0/sobjects/Account/001xx000003DHscAAG">
12 <Id>001xx000003DHscAAG</Id>
13 <Name>National Urban Technology Center</Name>
14 </autoSuggestResults>
15 <hasMoreResults>true</hasMoreResults>
16 <meta>
17 <nameFields>
18 <entityApiName>Account</entityApiName>
19 <fieldApiName>Name</fieldApiName>
20 </nameFields>
21 <nameFields>
22 <entityApiName>ContentDocument</entityApiName>
23 <fieldApiName>Title</fieldApiName>
24 </nameFields>
25 </meta>
26</suggestions>Unsupported Objects
The suggestions resource supports all searchable objects except the following.
- ContentNote
- Event
- External objects
- FeedComment
- FeedPost
- IdeaComment
- Pricebook2
- Reply
- TagDefinition
- Task