Newer Version Available

This content describes an older version of this product. View Latest

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 type
Available since release
32.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None required
Request parameters
Parameter Description
fields Optional. Used for creating lookup queries. Specify multiple fields using a comma-separated list. Specifies which lookup fields should be returned in the response.
groupId Optional. Specifies the unique identifier(s) of the group(s) that the question to return was posted to. Specify multiple groups using a comma-separated list. This parameter is only applicable when the parameter type equals question. Should not be used in combination with the userId.
limit Optional. Specifies the maximum number of suggested records to return. If a limit isn’t specified, five records are returned by default. If there are more suggested records than the limit specified, the response body’s hasMoreResults property is true.
networkId Optional. Specifies the unique identifier(s) for the community(ies) that the question to return is associated to. Specify multiple communities using a comma-separated list. This parameter is only applicable when the parameter type equals question or parameter sobject equals user.
q Required. The user’s search query string, properly URL-encoded. Suggestions are returned only if the user’s query string meets the minimum length requirements: one character for queries in Chinese, Japanese, Korean, and Thai; three characters for all other languages. Query strings that exceed the maximum length of 255 characters (or 200 consecutive characters without a space break) return an error.
sobject Required. The object that the search is scoped to, such as account or offer__c. If the sobject value is feedItem, it is required to have the type parameter with a value of question.
topicId Optional. Specifies the unique identifier of the single topic that the question to return was tagged as. This parameter is only applicable when the parameter type equals question.
type Required when the sobject value is feedItem. Including this parameter for all other sobject values will not affect the query. Specifies that the type of Feed is questions. Valid value: question.
userId Optional. Specifies the unique identifier(s) of the user(s) who authored the question to return. Specify multiple users using a comma-separated list. This parameter is only applicable when the parameter type equals question. Shouldn’t be used in combination with the groupId.
where Optional. A filter constraint following the same syntax as the SOQL where clause. For example: my_field__c LIKE 'foo%' AND RecordType='bar' This expression should be properly URL encoded.

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.

If the user’s search query contains quotation marks or wildcards, those symbols are automatically removed from the query string in the URI.

Note

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 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.

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:
  • Dashboard
  • Idea
  • IdeaTheme
  • Note
  • Question
In the absence of a standard Name or Title field, the main identifying field is used. For example, in cases, the Case Number is used.
Id The record’s unique identifier.

Example JSON Response Body

Example XML Response Body

Unsupported 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