Reference documentation and code samples for the Google Cloud Retail V2 Client class CustomAttribute.
A custom attribute that is not explicitly modeled inProduct.
Generated from protobuf messagegoogle.cloud.retail.v2.CustomAttribute
Namespace
Google \ Cloud \ Retail \ V2
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ text
array
The textual values of this custom attribute. For example,["yellow", "green"]when the key is "color". Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is returned. Exactly one oftextornumbersshould be set. Otherwise, an INVALID_ARGUMENT error is returned.
↳ numbers
array
The numerical values of this custom attribute. For example,[2.3, 15.4]when the key is "lengths_cm". Exactly one oftextornumbersshould be set. Otherwise, an INVALID_ARGUMENT error is returned.
↳ searchable
bool
This field is normally ignored unlessAttributesConfig.attribute_config_levelof theCatalogis set to the deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level attribute configuration, seeConfiguration modes. If true, custom attribute values are searchable by text queries inSearchService.Search. This field is ignored in aUserEvent. Only set if typetextis set. Otherwise, a INVALID_ARGUMENT error is returned.
The textual values of this custom attribute. For example,["yellow",
"green"]when the key is "color".
Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is
returned.
Exactly one oftextornumbersshould be set.
Otherwise, an INVALID_ARGUMENT error is returned.
The textual values of this custom attribute. For example,["yellow",
"green"]when the key is "color".
Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is
returned.
Exactly one oftextornumbersshould be set.
Otherwise, an INVALID_ARGUMENT error is returned.
Parameter
Name
Description
var
string[]
Returns
Type
Description
$this
getNumbers
The numerical values of this custom attribute. For example,[2.3, 15.4]when the key is "lengths_cm".
Exactly one oftextornumbersshould be set.
Otherwise, an INVALID_ARGUMENT error is returned.
If true, custom attribute values are searchable by text queries inSearchService.Search.
This field is ignored in aUserEvent.
Only set if typetextis
set. Otherwise, a INVALID_ARGUMENT error is returned.
If true, custom attribute values are searchable by text queries inSearchService.Search.
This field is ignored in aUserEvent.
Only set if typetextis
set. Otherwise, a INVALID_ARGUMENT error is returned.
[[["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 CustomAttribute (2.3.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.3.1 (latest)](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute)\n- [2.3.0](/php/docs/reference/cloud-retail/2.3.0/V2.CustomAttribute)\n- [2.2.1](/php/docs/reference/cloud-retail/2.2.1/V2.CustomAttribute)\n- [2.1.3](/php/docs/reference/cloud-retail/2.1.3/V2.CustomAttribute)\n- [2.0.0](/php/docs/reference/cloud-retail/2.0.0/V2.CustomAttribute)\n- [1.7.0](/php/docs/reference/cloud-retail/1.7.0/V2.CustomAttribute)\n- [1.6.4](/php/docs/reference/cloud-retail/1.6.4/V2.CustomAttribute)\n- [1.5.0](/php/docs/reference/cloud-retail/1.5.0/V2.CustomAttribute)\n- [1.4.2](/php/docs/reference/cloud-retail/1.4.2/V2.CustomAttribute)\n- [1.3.1](/php/docs/reference/cloud-retail/1.3.1/V2.CustomAttribute)\n- [1.2.1](/php/docs/reference/cloud-retail/1.2.1/V2.CustomAttribute)\n- [1.1.1](/php/docs/reference/cloud-retail/1.1.1/V2.CustomAttribute)\n- [1.0.1](/php/docs/reference/cloud-retail/1.0.1/V2.CustomAttribute) \nReference documentation and code samples for the Google Cloud Retail V2 Client class CustomAttribute.\n\nA custom attribute that is not explicitly modeled in\n[Product](/php/docs/reference/cloud-retail/latest/V2.Product).\n\nGenerated from protobuf message `google.cloud.retail.v2.CustomAttribute`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Retail \\\\ V2\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getText\n\nThe textual values of this custom attribute. For example, `[\"yellow\",\n\"green\"]` when the key is \"color\".\n\nEmpty string is not allowed. Otherwise, an INVALID_ARGUMENT error is\nreturned.\nExactly one of [text](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or\n[numbers](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.\nOtherwise, an INVALID_ARGUMENT error is returned.\n\n### setText\n\nThe textual values of this custom attribute. For example, `[\"yellow\",\n\"green\"]` when the key is \"color\".\n\nEmpty string is not allowed. Otherwise, an INVALID_ARGUMENT error is\nreturned.\nExactly one of [text](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or\n[numbers](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.\nOtherwise, an INVALID_ARGUMENT error is returned.\n\n### getNumbers\n\nThe numerical values of this custom attribute. For example, `[2.3, 15.4]`\nwhen the key is \"lengths_cm\".\n\nExactly one of [text](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or\n[numbers](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.\nOtherwise, an INVALID_ARGUMENT error is returned.\n\n### setNumbers\n\nThe numerical values of this custom attribute. For example, `[2.3, 15.4]`\nwhen the key is \"lengths_cm\".\n\nExactly one of [text](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or\n[numbers](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.\nOtherwise, an INVALID_ARGUMENT error is returned.\n\n### getSearchable\n\nThis field is normally ignored unless\n[AttributesConfig.attribute_config_level](/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)\nof the [Catalog](/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated\n'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level\nattribute configuration, see [Configuration\nmodes](https://cloud.google.com/retail/docs/attribute-config#config-modes).\n\nIf true, custom attribute values are searchable by text queries in\n[SearchService.Search](/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).\nThis field is ignored in a [UserEvent](/php/docs/reference/cloud-retail/latest/V2.UserEvent).\nOnly set if type [text](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) is\nset. Otherwise, a INVALID_ARGUMENT error is returned.\n\n### hasSearchable\n\n### clearSearchable\n\n### setSearchable\n\nThis field is normally ignored unless\n[AttributesConfig.attribute_config_level](/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)\nof the [Catalog](/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated\n'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level\nattribute configuration, see [Configuration\nmodes](https://cloud.google.com/retail/docs/attribute-config#config-modes).\n\nIf true, custom attribute values are searchable by text queries in\n[SearchService.Search](/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).\nThis field is ignored in a [UserEvent](/php/docs/reference/cloud-retail/latest/V2.UserEvent).\nOnly set if type [text](/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) is\nset. Otherwise, a INVALID_ARGUMENT error is returned.\n\n### getIndexable\n\nThis field is normally ignored unless\n[AttributesConfig.attribute_config_level](/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)\nof the [Catalog](/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated\n'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level\nattribute configuration, see [Configuration\nmodes](https://cloud.google.com/retail/docs/attribute-config#config-modes).\n\nIf true, custom attribute values are indexed, so that they can be filtered,\nfaceted or boosted in\n[SearchService.Search](/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).\nThis field is ignored in a [UserEvent](/php/docs/reference/cloud-retail/latest/V2.UserEvent).\nSee [SearchRequest.filter](/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__),\n[SearchRequest.facet_specs](/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFacetSpecs__)\nand\n[SearchRequest.boost_spec](/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getBoostSpec__)\nfor more details.\n\n### hasIndexable\n\n### clearIndexable\n\n### setIndexable\n\nThis field is normally ignored unless\n[AttributesConfig.attribute_config_level](/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)\nof the [Catalog](/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated\n'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level\nattribute configuration, see [Configuration\nmodes](https://cloud.google.com/retail/docs/attribute-config#config-modes).\n\nIf true, custom attribute values are indexed, so that they can be filtered,\nfaceted or boosted in\n[SearchService.Search](/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).\nThis field is ignored in a [UserEvent](/php/docs/reference/cloud-retail/latest/V2.UserEvent).\nSee [SearchRequest.filter](/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__),\n[SearchRequest.facet_specs](/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFacetSpecs__)\nand\n[SearchRequest.boost_spec](/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getBoostSpec__)\nfor more details."]]