Reference documentation and code samples for the Google Cloud Retail V2 Client class CompleteQueryRequest.
Autocomplete parameters.
Generated from protobuf message google.cloud.retail.v2.CompleteQueryRequest
Namespace
Google \ Cloud \ Retail \ V2
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ catalog
string
Required. Catalog for which the completion is performed. Full resource name of catalog, such as projects/*/locations/global/catalogs/default_catalog.
↳ query
string
Required. The query used to generate suggestions. The maximum number of allowed characters is 255.
↳ visitor_id
string
Recommended 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.
↳ language_codes
array
Note that this field applies for user-data dataset only. For requests with cloud-retail dataset, setting this field has no effect. 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.
↳ device_type
string
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. DESKTOP, MOBILE. If it is empty, the suggestions are across all device types. Supported formats: * * UNKNOWN_DEVICE_TYPE * * DESKTOP * * MOBILE * * A customized string starts with OTHER_, e.g. OTHER_IPHONE.
↳ dataset
string
Determines which dataset to use for fetching completion. "user-data" will use the dataset imported through CompletionService.ImportCompletionData. cloud-retail will use the dataset generated by Cloud Retail based on user events. If left empty, completions will be fetched from the user-data dataset. Current supported values: * * user-data * * cloud-retail: This option requires enabling auto-learning function first. See guidelines.
↳ max_suggestions
int
Completion max suggestions. If left unset or set to 0, then will fallback to the configured value CompletionConfig.max_suggestions. The maximum allowed max suggestions is 20. If it is set higher, it will be capped by 20.
↳ enable_attribute_suggestions
bool
If true, attribute suggestions are enabled and provided in the response. This field is only available for the cloud-retail dataset.
↳ entity
string
The entity for customers who run multiple entities, domains, sites, or regions, for example, Google US, Google Ads, Waymo, google.com, youtube.com, etc. If this is set, it must be an exact match with UserEvent.entity to get per-entity autocomplete results. This field will be applied to completion_results only. It has no effect on the attribute_results. Also, this entity should be limited to 256 characters, if too long, it will be truncated to 256 characters in both generation and serving time, and may lead to mis-match. To ensure it works, please set the entity with string within 256 characters.
getCatalog
Required. Catalog for which the completion is performed.
Full resource name of catalog, such as
projects/*/locations/global/catalogs/default_catalog.
Returns
Type
Description
string
setCatalog
Required. Catalog for which the completion is performed.
Full resource name of catalog, such as
projects/*/locations/global/catalogs/default_catalog.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getQuery
Required. The query used to generate suggestions.
The maximum number of allowed characters is 255.
Returns
Type
Description
string
setQuery
Required. The query used to generate suggestions.
The maximum number of allowed characters is 255.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getVisitorId
Recommended 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.
Returns
Type
Description
string
setVisitorId
Recommended 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.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getLanguageCodes
Note that this field applies for user-data dataset only. For requests
with cloud-retail dataset, setting this field has no effect.
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.
Note that this field applies for user-data dataset only. For requests
with cloud-retail dataset, setting this field has no effect.
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.
Parameter
Name
Description
var
string[]
Returns
Type
Description
$this
getDeviceType
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.
DESKTOP, MOBILE. If it is empty, the suggestions are across all device
types.
Supported formats:
UNKNOWN_DEVICE_TYPE
DESKTOP
MOBILE
A customized string starts with OTHER_, e.g. OTHER_IPHONE.
Returns
Type
Description
string
setDeviceType
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.
DESKTOP, MOBILE. If it is empty, the suggestions are across all device
types.
Supported formats:
UNKNOWN_DEVICE_TYPE
DESKTOP
MOBILE
A customized string starts with OTHER_, e.g. OTHER_IPHONE.
cloud-retail will use the dataset generated by Cloud Retail based on user
events. If left empty, completions will be fetched from the user-data
dataset.
Current supported values:
user-data
cloud-retail:
This option requires enabling auto-learning function first. See
guidelines.
cloud-retail will use the dataset generated by Cloud Retail based on user
events. If left empty, completions will be fetched from the user-data
dataset.
Current supported values:
user-data
cloud-retail:
This option requires enabling auto-learning function first. See
guidelines.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getMaxSuggestions
Completion max suggestions. If left unset or set to 0, then will fallback
to the configured value
CompletionConfig.max_suggestions.
The maximum allowed max suggestions is 20. If it is set higher, it will be
capped by 20.
Returns
Type
Description
int
setMaxSuggestions
Completion max suggestions. If left unset or set to 0, then will fallback
to the configured value
CompletionConfig.max_suggestions.
The maximum allowed max suggestions is 20. If it is set higher, it will be
capped by 20.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getEnableAttributeSuggestions
If true, attribute suggestions are enabled and provided in the response.
This field is only available for the cloud-retail dataset.
Returns
Type
Description
bool
setEnableAttributeSuggestions
If true, attribute suggestions are enabled and provided in the response.
This field is only available for the cloud-retail dataset.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getEntity
The entity for customers who run multiple entities, domains, sites, or
regions, for example, Google US, Google Ads, Waymo,
google.com, youtube.com, etc.
If this is set, it must be an exact match with
UserEvent.entity to get
per-entity autocomplete results. This field will be applied to
completion_results only. It has no effect on the attribute_results.
Also, this entity should be limited to 256 characters, if too long, it will
be truncated to 256 characters in both generation and serving time, and may
lead to mis-match. To ensure it works, please set the entity with string
within 256 characters.
Returns
Type
Description
string
setEntity
The entity for customers who run multiple entities, domains, sites, or
regions, for example, Google US, Google Ads, Waymo,
google.com, youtube.com, etc.
If this is set, it must be an exact match with
UserEvent.entity to get
per-entity autocomplete results. This field will be applied to
completion_results only. It has no effect on the attribute_results.
Also, this entity should be limited to 256 characters, if too long, it will
be truncated to 256 characters in both generation and serving time, and may
lead to mis-match. To ensure it works, please set the entity with string
within 256 characters.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud Retail V2 Client - Class CompleteQueryRequest (2.3.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.3.1 (latest)](/php/docs/reference/cloud-retail/latest/V2.CompleteQueryRequest)\n- [2.3.0](/php/docs/reference/cloud-retail/2.3.0/V2.CompleteQueryRequest)\n- [2.2.1](/php/docs/reference/cloud-retail/2.2.1/V2.CompleteQueryRequest)\n- [2.1.3](/php/docs/reference/cloud-retail/2.1.3/V2.CompleteQueryRequest)\n- [2.0.0](/php/docs/reference/cloud-retail/2.0.0/V2.CompleteQueryRequest)\n- [1.7.0](/php/docs/reference/cloud-retail/1.7.0/V2.CompleteQueryRequest)\n- [1.6.4](/php/docs/reference/cloud-retail/1.6.4/V2.CompleteQueryRequest)\n- [1.5.0](/php/docs/reference/cloud-retail/1.5.0/V2.CompleteQueryRequest)\n- [1.4.2](/php/docs/reference/cloud-retail/1.4.2/V2.CompleteQueryRequest)\n- [1.3.1](/php/docs/reference/cloud-retail/1.3.1/V2.CompleteQueryRequest)\n- [1.2.1](/php/docs/reference/cloud-retail/1.2.1/V2.CompleteQueryRequest)\n- [1.1.1](/php/docs/reference/cloud-retail/1.1.1/V2.CompleteQueryRequest)\n- [1.0.1](/php/docs/reference/cloud-retail/1.0.1/V2.CompleteQueryRequest) \nReference documentation and code samples for the Google Cloud Retail V2 Client class CompleteQueryRequest.\n\nAutocomplete parameters.\n\nGenerated from protobuf message `google.cloud.retail.v2.CompleteQueryRequest`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Retail \\\\ V2\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getCatalog\n\nRequired. Catalog for which the completion is performed.\n\nFull resource name of catalog, such as\n`projects/*/locations/global/catalogs/default_catalog`.\n\n### setCatalog\n\nRequired. Catalog for which the completion is performed.\n\nFull resource name of catalog, such as\n`projects/*/locations/global/catalogs/default_catalog`.\n\n### getQuery\n\nRequired. The query used to generate suggestions.\n\nThe maximum number of allowed characters is 255.\n\n### setQuery\n\nRequired. The query used to generate suggestions.\n\nThe maximum number of allowed characters is 255.\n\n### getVisitorId\n\nRecommended field. A unique identifier for tracking visitors. For example,\nthis could be implemented with an HTTP cookie, which should be able to\nuniquely identify a visitor on a single device. This unique identifier\nshould not change if the visitor logs in or out of the website.\n\nThe field must be a UTF-8 encoded string with a length limit of 128\ncharacters. Otherwise, an INVALID_ARGUMENT error is returned.\n\n### setVisitorId\n\nRecommended field. A unique identifier for tracking visitors. For example,\nthis could be implemented with an HTTP cookie, which should be able to\nuniquely identify a visitor on a single device. This unique identifier\nshould not change if the visitor logs in or out of the website.\n\nThe field must be a UTF-8 encoded string with a length limit of 128\ncharacters. Otherwise, an INVALID_ARGUMENT error is returned.\n\n### getLanguageCodes\n\nNote that this field applies for `user-data` dataset only. For requests\nwith `cloud-retail` dataset, setting this field has no effect.\n\nThe language filters applied to the output suggestions. If set, it should\ncontain the language of the query. If not set, suggestions are returned\nwithout considering language restrictions. This is the BCP-47 language\ncode, such as \"en-US\" or \"sr-Latn\". For more information, see [Tags for\nIdentifying Languages](https://tools.ietf.org/html/bcp47). The maximum\nnumber of language codes is 3.\n\n### setLanguageCodes\n\nNote that this field applies for `user-data` dataset only. For requests\nwith `cloud-retail` dataset, setting this field has no effect.\n\nThe language filters applied to the output suggestions. If set, it should\ncontain the language of the query. If not set, suggestions are returned\nwithout considering language restrictions. This is the BCP-47 language\ncode, such as \"en-US\" or \"sr-Latn\". For more information, see [Tags for\nIdentifying Languages](https://tools.ietf.org/html/bcp47). The maximum\nnumber of language codes is 3.\n\n### getDeviceType\n\nThe device type context for completion suggestions. We recommend that you\nleave this field empty.\n\nIt can apply different suggestions on different device types, e.g.\n`DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device\ntypes.\nSupported formats:\n\n- `UNKNOWN_DEVICE_TYPE`\n- `DESKTOP`\n- `MOBILE`\n- A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.\n\n### setDeviceType\n\nThe device type context for completion suggestions. We recommend that you\nleave this field empty.\n\nIt can apply different suggestions on different device types, e.g.\n`DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device\ntypes.\nSupported formats:\n\n- `UNKNOWN_DEVICE_TYPE`\n- `DESKTOP`\n- `MOBILE`\n- A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.\n\n### getDataset\n\nDetermines which dataset to use for fetching completion. \"user-data\" will\nuse the dataset imported through\n[CompletionService.ImportCompletionData](/php/docs/reference/cloud-retail/latest/V2.Client.CompletionServiceClient#_Google_Cloud_Retail_V2_Client_CompletionServiceClient__importCompletionData__).\n\n`cloud-retail` will use the dataset generated by Cloud Retail based on user\nevents. If left empty, completions will be fetched from the `user-data`\ndataset.\nCurrent supported values:\n\n- user-data\n- cloud-retail: This option requires enabling auto-learning function first. See [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset).\n\n### setDataset\n\nDetermines which dataset to use for fetching completion. \"user-data\" will\nuse the dataset imported through\n[CompletionService.ImportCompletionData](/php/docs/reference/cloud-retail/latest/V2.Client.CompletionServiceClient#_Google_Cloud_Retail_V2_Client_CompletionServiceClient__importCompletionData__).\n\n`cloud-retail` will use the dataset generated by Cloud Retail based on user\nevents. If left empty, completions will be fetched from the `user-data`\ndataset.\nCurrent supported values:\n\n- user-data\n- cloud-retail: This option requires enabling auto-learning function first. See [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset).\n\n### getMaxSuggestions\n\nCompletion max suggestions. If left unset or set to 0, then will fallback\nto the configured value\n[CompletionConfig.max_suggestions](/php/docs/reference/cloud-retail/latest/V2.CompletionConfig#_Google_Cloud_Retail_V2_CompletionConfig__getMaxSuggestions__).\n\nThe maximum allowed max suggestions is 20. If it is set higher, it will be\ncapped by 20.\n\n### setMaxSuggestions\n\nCompletion max suggestions. If left unset or set to 0, then will fallback\nto the configured value\n[CompletionConfig.max_suggestions](/php/docs/reference/cloud-retail/latest/V2.CompletionConfig#_Google_Cloud_Retail_V2_CompletionConfig__getMaxSuggestions__).\n\nThe maximum allowed max suggestions is 20. If it is set higher, it will be\ncapped by 20.\n\n### getEnableAttributeSuggestions\n\nIf true, attribute suggestions are enabled and provided in the response.\n\nThis field is only available for the `cloud-retail` dataset.\n\n### setEnableAttributeSuggestions\n\nIf true, attribute suggestions are enabled and provided in the response.\n\nThis field is only available for the `cloud-retail` dataset.\n\n### getEntity\n\nThe entity for customers who run multiple entities, domains, sites, or\nregions, for example, `Google US`, `Google Ads`, `Waymo`,\n`google.com`, `youtube.com`, etc.\n\nIf this is set, it must be an exact match with\n[UserEvent.entity](/php/docs/reference/cloud-retail/latest/V2.UserEvent#_Google_Cloud_Retail_V2_UserEvent__getEntity__) to get\nper-entity autocomplete results. This field will be applied to\n`completion_results` only. It has no effect on the `attribute_results`.\nAlso, this entity should be limited to 256 characters, if too long, it will\nbe truncated to 256 characters in both generation and serving time, and may\nlead to mis-match. To ensure it works, please set the entity with string\nwithin 256 characters.\n\n### setEntity\n\nThe entity for customers who run multiple entities, domains, sites, or\nregions, for example, `Google US`, `Google Ads`, `Waymo`,\n`google.com`, `youtube.com`, etc.\n\nIf this is set, it must be an exact match with\n[UserEvent.entity](/php/docs/reference/cloud-retail/latest/V2.UserEvent#_Google_Cloud_Retail_V2_UserEvent__getEntity__) to get\nper-entity autocomplete results. This field will be applied to\n`completion_results` only. It has no effect on the `attribute_results`.\nAlso, this entity should be limited to 256 characters, if too long, it will\nbe truncated to 256 characters in both generation and serving time, and may\nlead to mis-match. To ensure it works, please set the entity with string\nwithin 256 characters."]]