[[["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 Rule (2.3.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.3.1 (latest)](/php/docs/reference/cloud-retail/latest/V2.Rule)\n- [2.3.0](/php/docs/reference/cloud-retail/2.3.0/V2.Rule)\n- [2.2.1](/php/docs/reference/cloud-retail/2.2.1/V2.Rule)\n- [2.1.3](/php/docs/reference/cloud-retail/2.1.3/V2.Rule)\n- [2.0.0](/php/docs/reference/cloud-retail/2.0.0/V2.Rule)\n- [1.7.0](/php/docs/reference/cloud-retail/1.7.0/V2.Rule)\n- [1.6.4](/php/docs/reference/cloud-retail/1.6.4/V2.Rule)\n- [1.5.0](/php/docs/reference/cloud-retail/1.5.0/V2.Rule)\n- [1.4.2](/php/docs/reference/cloud-retail/1.4.2/V2.Rule)\n- [1.3.1](/php/docs/reference/cloud-retail/1.3.1/V2.Rule)\n- [1.2.1](/php/docs/reference/cloud-retail/1.2.1/V2.Rule)\n- [1.1.1](/php/docs/reference/cloud-retail/1.1.1/V2.Rule)\n- [1.0.1](/php/docs/reference/cloud-retail/1.0.1/V2.Rule) \nReference documentation and code samples for the Google Cloud Retail V2 Client class Rule.\n\nA rule is a condition-action pair\n\n- A condition defines when a rule is to be triggered.\n\n- An action specifies what occurs on that trigger.\n Currently rules only work for [controls](/php/docs/reference/cloud-retail/latest/V2.Control) with\n [SOLUTION_TYPE_SEARCH](/php/docs/reference/cloud-retail/latest/V2.SolutionType#_Google_Cloud_Retail_V2_SolutionType__SOLUTION_TYPE_SEARCH).\n\nGenerated from protobuf message `google.cloud.retail.v2.Rule`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Retail \\\\ V2\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getBoostAction\n\nA boost action.\n\n### hasBoostAction\n\n### setBoostAction\n\nA boost action.\n\n### getRedirectAction\n\nRedirects a shopper to a specific page.\n\n### hasRedirectAction\n\n### setRedirectAction\n\nRedirects a shopper to a specific page.\n\n### getOnewaySynonymsAction\n\nTreats specific term as a synonym with a group of terms.\n\nGroup of terms will not be treated as synonyms with the specific term.\n\n### hasOnewaySynonymsAction\n\n### setOnewaySynonymsAction\n\nTreats specific term as a synonym with a group of terms.\n\nGroup of terms will not be treated as synonyms with the specific term.\n\n### getDoNotAssociateAction\n\nPrevents term from being associated with other terms.\n\n### hasDoNotAssociateAction\n\n### setDoNotAssociateAction\n\nPrevents term from being associated with other terms.\n\n### getReplacementAction\n\nReplaces specific terms in the query.\n\n### hasReplacementAction\n\n### setReplacementAction\n\nReplaces specific terms in the query.\n\n### getIgnoreAction\n\nIgnores specific terms from query during search.\n\n### hasIgnoreAction\n\n### setIgnoreAction\n\nIgnores specific terms from query during search.\n\n### getFilterAction\n\nFilters results.\n\n### hasFilterAction\n\n### setFilterAction\n\nFilters results.\n\n### getTwowaySynonymsAction\n\nTreats a set of terms as synonyms of one another.\n\n### hasTwowaySynonymsAction\n\n### setTwowaySynonymsAction\n\nTreats a set of terms as synonyms of one another.\n\n### getForceReturnFacetAction\n\nForce returns an attribute as a facet in the request.\n\n### hasForceReturnFacetAction\n\n### setForceReturnFacetAction\n\nForce returns an attribute as a facet in the request.\n\n### getRemoveFacetAction\n\nRemove an attribute as a facet in the request (if present).\n\n### hasRemoveFacetAction\n\n### setRemoveFacetAction\n\nRemove an attribute as a facet in the request (if present).\n\n### getPinAction\n\nPins one or more specified products to a specific position in the\nresults.\n\n### hasPinAction\n\n### setPinAction\n\nPins one or more specified products to a specific position in the\nresults.\n\n### getCondition\n\nRequired. The condition that triggers the rule.\n\nIf the condition is empty, the rule will always apply.\n\n### hasCondition\n\n### clearCondition\n\n### setCondition\n\nRequired. The condition that triggers the rule.\n\nIf the condition is empty, the rule will always apply.\n\n### getAction"]]