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 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.
The order of results is determined by a relevance 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. 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 "attributes" : {
3 "type" : "Account",
4 "url" : "/services/data/v32.0/sobjects/Account/001xx000003DH6WAAW"
5 },
6 "Id" : "001xx000003DH6WAAW"
7 "Name" : "National Utility Service"
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 JSON Response Body for a Multiple Object Request
1[ {
2 "attributes" : {
3 "type" : "Account",
4 "url" : "/services/data/v38.0/sobjects/Account/001xx000003DMEKAA4"
5 },
6 "Id" : "001xx000003DMEKAA4"
7 "Name" : "Joe Doe Printing"
8}, {
9{
10 "attributes" : {
11 "type" : "Account",
12 "url" : "/services/data/v38.0/sobjects/Account/001xx000003DLjvAAG"
13 },
14 "Id" : "001xx000003DLjvAAGO"
15 "Name" : "Joe Doe Plumbing"
16}, {
17{
18 "attributes" : {
19 "type" : "Contact",
20 "url" : "/services/data/v38.0/sobjects/Contact/003xx000004U9Y9AAK"
21 },
22 "Id" : "003xx000004U9Y9AAK"
23 "Name" : "John Doe"
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 Service</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>Unsupported Objects
The suggestions resource supports all searchable objects except the following.
- ContentNote
- Event
- External objects
- FeedComment
- FeedPost
- IdeaComment
- Pricebook2
- Reply
- TagDefinition
- Task