Newer Version Available
Search for Records Suggested by Autocomplete and Instant Results
Syntax
- URI
- /services/data/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
-
Parameter Description fields Optional. Used for creating lookup queries. Specify multiple fields using a comma-separated list. Specifies which lookup fields to be returned in the response. dynamicFields Optional. Available in API version 48.0 and later. Used to return additional dynamic fields. Specify multiple options using a comma-separated list. For example, if dynamicFields=secondaryField then each suggested record in the results contains an additional field besides Id and Name (or Title) based on the next eligible field in the search layout. groupId Optional. Specifies one or more unique identifiers of one or more groups 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. Don’t use with the userId. ignoreUnsupportedSObjects Optional. If an unsupported object is included in a request, this parameter indicates what action to take. If it’s set to false, an error is returned. If it’s set to true, the object is ignored and no error is returned. See the Unsupported Objects section for reference. The default is false. limit Optional. Specifies the maximum number of suggested records to return. If a limit isn’t specified, 5 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 one or more unique identifiers for the Experience Cloud sites to return the question to. Specify multiple sites 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 objects that the search is scoped to, such as Account or offer__c. If the sobject value is feedItem, the type parameter is required and it must have a value of question.
Specify up to 10 objects with a comma-separated list. For example: sobject=Account,Contact,Lead. To take advantage of the feature, activate the CrossObjectTypeahead permission.
To specify the specific fields to return by object, use the following syntax with multiple fields in a comma-separated list. The sobject is lowercase.For example:
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 doesn’t affect the query. Specifies that the type of Feed is questions. Valid value: question. userId Optional. Specifies one or more unique identifiers of one or more users 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. Don’t use with the groupId. useSearchScope Optional. Available in API version 40.0 and later. The default value is false. If false, the objects specified in the request are used to suggest records. If true, in addition to the objects specified in the request, the user's search scope is used to suggest records. The search scope is the list of objects a user uses most frequently. - If the request doesn’t specify an object, use useSearchScope=true.
- If useSearchScope=true and the user's search scope is empty, the default search scope is used to suggest records.
- Typically, only the first 10 objects are used to suggest records. However, an admin can assign objects that are always considered when returning results. If configured, up to 15 objects are used to suggest records. For more information about assigning objects, see Assign Search Results Objects to Users (Beta).
- Objects specified in the sobject parameter are prioritized over objects in the user's search scope.
- Values for the ignoreUnsupportedSObjects parameter aren’t applied to the objects in the search scope.
This example uses only the search scope.This example uses the search scope and the Account object.where Optional. A filter that follows the same syntax as the SOQL WHERE clause. URLs encode the expression. Use the clause for an object, or globally for all compatible objects. An example of an object-specific clause is: account.where=name%20LIKE%20%27Smith%25%27. An example of a global clause is: where=name%20LIKE%20%27Smith%25%27. The parameter must be lower case. Any object-specific where clauses override the global where clause. You can’t use this parameter for the Question object.
To specify multiple entities, see the following example. This feature is available in version 38.0 and later.
Usage
Example
Suggested Records Response
A relevance algorithm determines the order of results.
| 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
Example JSON Response Body for a Multiple Object Request
Example XML Response Body
Unsupported Objects
- ContentNote
- Event
- External objects
- FeedComment
- FeedPost
- IdeaComment
- Pricebook2
- Reply
- TagDefinition
- Task