Newer Version Available
Search Suggested Records
Returns a list of suggested records whose names match the
user’s search string. The suggestions resource provides a shortcut for users to navigate
directly to likely relevant records, before performing a search.
Syntax
- URI
- vXX.X/search/suggestions?q=search string&sobject=object type
- 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 starts with the exact text in the search string. The suggestions resource automatically
appends an asterisk wildcard (*) at the end of the search string. Records that contain the
search string within a word aren’t considered a match.
Records are suggested if the entire search string is found in the record name, in the same order as specified in the search string.
Example
For example, the text string national u is treated as
national u* and returns “National Utility” and “National Urban
Company” but not “National Company Utility” or “Urban National Company”.
Suggested Records Response
The suggestions resource returns display-ready
data about likely relevant records that the user can access. This resource can be used in
conjunction with other services that use the IDs to get data for display.
The order of results is determined by a relevancy algorithm.
Each suggested record in the results
contains these elements:
| Element | Description |
|---|---|
| Attributes | The record’s object type and the URL for accessing the record. |
| 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 "attributes" : {
3 "type" : "Account",
4 "url" : "/services/data/v32.0/sobjects/Account/001xx000003DH6WAAW"
5 },
6 "Id" : "001xx000003DH6WAAW"
7 "Name" : "National Utility Company"
8}, {
9{
10 "attributes" : {
11 "type" : "Account",
12 "url" : "/services/data/v32.0/sobjects/Account/001xx000003DHJ4AAO"
13 },
14 "Id" : "001xx000003DHJ4AAO"
15 "Name" : "National Utility Service"
16}, {
17{
18 "attributes" : {
19 "type" : "Account",
20 "url" : "/services/data/v32.0/sobjects/Account/001xx000003DHscAAG"
21 },
22 "Id" : "001xx000003DHscAAG"
23 "Name" : "National Urban Technology Center"
24} ]Example XML Response Body
1<?xml version=”1.0” encoding=”UTF-8”?
2<suggestions>
3 <autoSuggestResults type="Account" url="/services/data/v32.0/sobjects/Account/001xx000003DH6WAAW">
4 <Id>001xx000003DH6WAAW</Id>
5 <Name>National Utility Company</Name>
6 </autoSuggestResults>
7 <autoSuggestResults type="Account" url="/services/data/v32.0/sobjects/Account/001xx000003DHJ4AAO">
8 <Id>001xx000003DHJ4AAO</Id>
9 <Name>National Utility Service</Name>
10 </autoSuggestResults>
11 <autoSuggestResults type="Account" url="/services/data/v32.0/sobjects/Account/001xx000003DHscAAG">
12 <Id>001xx000003DHscAAG</Id>
13 <Name>National Urban Technology Center</Name>
14 </autoSuggestResults>
15 <hasMoreResults>true</hasMoreResults>
16</suggestions>Supported Objects
The suggestions resource supports all objects except these.
- Article (Use the suggestTitleMatches resource to return a list of Salesforce Knowledge articles whose titles match the user’s search query string.)
- ContentNote
- Event
- FeedComment
- FeedPost
- IdeaComment
- Pricebook2
- Reply
- TagDefinition
- Task