- HTTP request
- Path parameters
- Query parameters
- Request body
- Response body
- Authorization scopes
- IAM Permissions
- CompletionResult
- RecentSearchResult
- AttributeResult
- Try it!
Completes the specified prefix with keyword suggestions.
This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
HTTP request
GET https://retail.googleapis.com/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
catalog |
Required. Catalog for which the completion is performed. Full resource name of catalog, such as |
Query parameters
Parameters | |
---|---|
query |
Required. The query used to generate suggestions. The maximum number of allowed characters is 255. |
visitorId |
Required field. A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor logs in or out of the website. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. |
languageCodes[] |
Note that this field applies for The language filters applied to the output suggestions. If set, it should contain the language of the query. If not set, suggestions are returned without considering language restrictions. This is the BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see Tags for Identifying Languages. The maximum number of language codes is 3. |
deviceType |
The device type context for completion suggestions. We recommend that you leave this field empty. It can apply different suggestions on different device types, e.g. Supported formats:
|
dataset |
Determines which dataset to use for fetching completion. "user-data" will use the imported dataset through Current supported values:
|
maxSuggestions |
Completion max suggestions. If left unset or set to 0, then will fallback to the configured value The maximum allowed max suggestions is 20. If it is set higher, it will be capped by 20. |
enableAttributeSuggestions |
If true, attribute suggestions are enabled and provided in the response. This field is only available for the "cloud-retail" dataset. |
entity |
The entity for customers who run multiple entities, domains, sites, or regions, for example, |
Request body
The request body must be empty.
Response body
Response of the autocomplete query.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "completionResults": [ { object ( |
Fields | |
---|---|
completionResults[] |
Results of the matching suggestions. The result list is ordered and the first result is top suggestion. |
attributionToken |
A unique complete token. This should be included in the |
recentSearchResults[] |
Deprecated. Matched recent searches of this user. The maximum number of recent searches is 10. This field is a restricted feature. If you want to enable it, contact Retail Search support. This feature is only available when
Recent searches are deduplicated. More recent searches will be reserved when duplication happens. |
attributeResults |
A map of matched attribute suggestions. This field is only available for "cloud-retail" dataset. Current supported keys:
|
Authorization scopes
Requires the following OAuth scope:
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
IAM Permissions
Requires the following IAM permission on the catalog
resource:
retail.catalogs.completeQuery
For more information, see the IAM documentation.
CompletionResult
Resource that represents completion results.
JSON representation |
---|
{
"suggestion": string,
"attributes": {
string: {
"text": [
string
],
"numbers": [
number
],
"searchable": boolean,
"indexable": boolean
},
...
},
"facets": [
{
object ( |
Fields | |
---|---|
suggestion |
The suggestion for the query. |
attributes |
Custom attributes for the suggestion term.
|
attributes.text[] |
The textual values of this custom attribute. For example, Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is returned. Exactly one of |
attributes.numbers[] |
The numerical values of this custom attribute. For example, Exactly one of |
attributes.searchable |
This field is normally ignored unless This field is ignored in a Only set if type |
attributes.indexable |
This field is normally ignored unless This field is ignored in a See |
facets[] |
Facet information for the suggestion term. Gives the number of items resulting from a search with this suggestion term for each facet. This is an experimental feature for limited customers. If you want to receive this facet information, reach out to the Retail support team. |
totalProductCount |
Total number of products associated with a search with this suggestion. This is an experimental feature for limited customers. If you want to receive this product count information, reach out to the Retail support team. |
RecentSearchResult
Deprecated: Recent search of this user.
JSON representation |
---|
{ "recentSearch": string } |
Fields | |
---|---|
recentSearch |
The recent search query. |
AttributeResult
Resource that represents attribute results. The list of suggestions for the attribute.
JSON representation |
---|
{ "suggestions": [ string ] } |
Fields | |
---|---|
suggestions[] |
|