Class Rule (1.23.1)

Rule(mapping=None, *, ignore_unknown_fields=False, **kwargs)

A rule is a condition-action pair

  • A condition defines when a rule is to be triggered.
  • An action specifies what occurs on that trigger. Currently rules only work for controls with SOLUTION_TYPE_SEARCH.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes

Name Description
boost_action google.cloud.retail_v2alpha.types.Rule.BoostAction
A boost action. This field is a member of oneof_ action.
redirect_action google.cloud.retail_v2alpha.types.Rule.RedirectAction
Redirects a shopper to a specific page. This field is a member of oneof_ action.
oneway_synonyms_action google.cloud.retail_v2alpha.types.Rule.OnewaySynonymsAction
Treats specific term as a synonym with a group of terms. Group of terms will not be treated as synonyms with the specific term. This field is a member of oneof_ action.
do_not_associate_action google.cloud.retail_v2alpha.types.Rule.DoNotAssociateAction
Prevents term from being associated with other terms. This field is a member of oneof_ action.
replacement_action google.cloud.retail_v2alpha.types.Rule.ReplacementAction
Replaces specific terms in the query. This field is a member of oneof_ action.
ignore_action google.cloud.retail_v2alpha.types.Rule.IgnoreAction
Ignores specific terms from query during search. This field is a member of oneof_ action.
filter_action google.cloud.retail_v2alpha.types.Rule.FilterAction
Filters results. This field is a member of oneof_ action.
twoway_synonyms_action google.cloud.retail_v2alpha.types.Rule.TwowaySynonymsAction
Treats a set of terms as synonyms of one another. This field is a member of oneof_ action.
force_return_facet_action google.cloud.retail_v2alpha.types.Rule.ForceReturnFacetAction
Force returns an attribute as a facet in the request. This field is a member of oneof_ action.
remove_facet_action google.cloud.retail_v2alpha.types.Rule.RemoveFacetAction
Remove an attribute as a facet in the request (if present). This field is a member of oneof_ action.
condition google.cloud.retail_v2alpha.types.Condition
Required. The condition that triggers the rule. If the condition is empty, the rule will always apply.

Classes

BoostAction

BoostAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

A boost action to apply to results matching condition specified above.

DoNotAssociateAction

DoNotAssociateAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Prevents query_term from being associated with specified terms during search. Example: Don't associate "gShoe" and "cheap".

FilterAction

FilterAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)
  • Rule Condition:

    • No Condition.query_terms provided is a global match.
    • 1 or more Condition.query_terms provided are combined with OR operator.
  • Action Input: The request query and filter that are applied to the retrieved products, in addition to any filters already provided with the SearchRequest. The AND operator is used to combine the query's existing filters with the filter rule(s). NOTE: May result in 0 results when filters conflict.

  • Action Result: Filters the returned objects to be ONLY those that passed the filter.

ForceReturnFacetAction

ForceReturnFacetAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Force returns an attribute/facet in the request around a certain position or above.

  • Rule Condition: Must specify non-empty Condition.query_terms (for search only) or Condition.page_categories (for browse only), but can't specify both.

  • Action Inputs: attribute name, position

  • Action Result: Will force return a facet key around a certain position or above if the condition is satisfied.

Example: Suppose the query is "shoes", the Condition.query_terms is "shoes", the ForceReturnFacetAction.FacetPositionAdjustment.attribute_name is "size" and the ForceReturnFacetAction.FacetPositionAdjustment.position is 8.

Two cases: a) The facet key "size" is not already in the top 8 slots, then the facet "size" will appear at a position close to 8. b) The facet key "size" in among the top 8 positions in the request, then it will stay at its current rank.

IgnoreAction

IgnoreAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Prevents a term in the query from being used in search. Example: Don't search for "shoddy".

OnewaySynonymsAction

OnewaySynonymsAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Maps a set of terms to a set of synonyms. Set of synonyms will be treated as synonyms of each query term only. query_terms will not be treated as synonyms of each other. Example: "sneakers" will use a synonym of "shoes". "shoes" will not use a synonym of "sneakers".

RedirectAction

RedirectAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Redirects a shopper to a specific page.

  • Rule Condition: Must specify Condition.query_terms.
  • Action Input: Request Query
  • Action Result: Redirects shopper to provided uri.

RemoveFacetAction

RemoveFacetAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Removes an attribute/facet in the request if is present.

  • Rule Condition: Must specify non-empty Condition.query_terms (for search only) or Condition.page_categories (for browse only), but can't specify both.

  • Action Input: attribute name

  • Action Result: Will remove the attribute (as a facet) from the request if it is present.

Example: Suppose the query is "shoes", the Condition.query_terms is "shoes" and the attribute name "size", then facet key "size" will be removed from the request (if it is present).

ReplacementAction

ReplacementAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Replaces a term in the query. Multiple replacement candidates can be specified. All query_terms will be replaced with the replacement term. Example: Replace "gShoe" with "google shoe".

TwowaySynonymsAction

TwowaySynonymsAction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Creates a set of terms that will be treated as synonyms of each other. Example: synonyms of "sneakers" and "shoes":

  • "sneakers" will use a synonym of "shoes".
  • "shoes" will use a synonym of "sneakers".