Skip to content

aws.personalize_runtime.get_recommendations

Example SQL Queries

SELECT * FROM
aws.personalize_runtime.get_recommendations;

Description

Returns a list of recommended items. For campaigns, the campaign's Amazon Resource Name (ARN) is required and the required user and item input depends on the recipe type used to create the solution backing the campaign as follows:

  • USER_PERSONALIZATION - userId required, itemId not used

  • RELATED_ITEMS - itemId required, userId not used

Campaigns that are backed by a solution created using a recipe of type PERSONALIZED_RANKING use the API.

For recommenders, the recommender's ARN is required and the required item and user input depends on the use case (domain-based recipe) backing the recommender. For information on use case requirements see Choosing recommender use cases.

Table Definition

Column NameColumn Data Type
campaign_arn Input Column

The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.

VARCHAR
context Input Column

The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.

MAP(VARCHAR, VARCHAR)
filter_arn Input Column

The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations.

When using this parameter, be sure the filter resource is ACTIVE.

VARCHAR
filter_values Input Column

The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma.

For filter expressions that use an INCLUDE element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude items, you can omit the filter-values.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.

For more information, see Filtering recommendations and user segments.

MAP(VARCHAR, VARCHAR)
item_id Input Column

The item ID to provide recommendations for.

Required for RELATED_ITEMS recipe type.

VARCHAR
metadata_columns Input Column

If you enabled metadata in recommendations when you created or updated the campaign or recommender, specify the metadata columns from your Items dataset to include in item recommendations. The map key is ITEMS and the value is a list of column names from your Items dataset. The maximum number of columns you can provide is 10.

For information about enabling metadata for a campaign, see Enabling metadata in recommendations for a campaign. For information about enabling metadata for a recommender, see Enabling metadata in recommendations for a recommender.

MAP(VARCHAR, VARCHAR[])
num_results Input Column

The number of results to return. The default is 25. If you are including metadata in recommendations, the maximum is 50. Otherwise, the maximum is 500.

BIGINT
promotions Input Column

The promotions to apply to the recommendation request. A promotion defines additional business rules that apply to a configurable subset of recommended items.

STRUCT(
"name" VARCHAR,
"percent_promoted_items" BIGINT,
"filter_arn" VARCHAR,
"filter_values" MAP(VARCHAR, VARCHAR)
)[]
Show child fields
promotions[]
Show child fields
promotions[].filter_arn

The Amazon Resource Name (ARN) of the filter used by the promotion. This filter defines the criteria for promoted items. For more information, see Promotion filters.

promotions[].filter_values

The values to use when promoting items. For each placeholder parameter in your promotion's filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma.

For filter expressions that use an INCLUDE element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude items, you can omit the filter-values. In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.

For more information on creating filters, see Filtering recommendations and user segments.

promotions[].name

The name of the promotion.

promotions[].percent_promoted_items

The percentage of recommended items to apply the promotion to.

recommender_arn Input Column

The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you created a Domain dataset group with a recommender for a domain use case.

VARCHAR
user_id Input Column

The user ID to provide recommendations for.

Required for USER_PERSONALIZATION recipe type.

VARCHAR
_aws_profile Input Column

The AWS profile defines the AWS identity used. It can be defined via credentials or by assuming a IAM role.

STRUCT(
"type" VARCHAR,
"name" VARCHAR,
"account_id" VARCHAR,
"via_profile_name" VARCHAR,
"assumed_role_arn" VARCHAR,
"organization" STRUCT(
"account_name" VARCHAR,
"id" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"master_account" STRUCT(
"id" VARCHAR,
"email" VARCHAR
),
"parents" STRUCT(
"type" VARCHAR,
"id" VARCHAR,
"name" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[]
)[]
)
)
Show child fields
_aws_profile.account_id

The AWS account id

_aws_profile.assumed_role_arn

The ARN of the assumed role

_aws_profile.name

The unique name of the profile.

_aws_profile.organization

Information about this profile's membership in the AWS organization.

Show child fields
_aws_profile.organization.account_name

The name of account speciifed by the organization

_aws_profile.organization.id

The organization id

_aws_profile.organization.master_account
Show child fields
_aws_profile.organization.master_account.email

The organization master account email address

_aws_profile.organization.master_account.id

The organization master account id

_aws_profile.organization.parents[]
Show child fields
_aws_profile.organization.parents[].id

The id of the parent

_aws_profile.organization.parents[].name

The name of the parent

_aws_profile.organization.parents[].tags[]
Show child fields
_aws_profile.organization.parents[].tags[].key
_aws_profile.organization.parents[].tags[].value
_aws_profile.organization.parents[].type

The type of parent can be an organization unit or a root

_aws_profile.organization.tags[]
Show child fields
_aws_profile.organization.tags[].key
_aws_profile.organization.tags[].value
_aws_profile.type

The type of profile, either 'credentials' or 'assumed_role'

_aws_profile.via_profile_name

This IAM role for this profile is assumed by first utilizing another profile with this name to obtain credentials.

item_list

A list of recommendations sorted in descending order by prediction score. There can be a maximum of 500 items in the list.

STRUCT(
"item_id" VARCHAR,
"score" DOUBLE,
"promotion_name" VARCHAR,
"metadata" MAP(VARCHAR, VARCHAR),
"reason" VARCHAR[]
)[]
Show child fields
item_list[]
Show child fields
item_list[].item_id

The recommended item ID.

item_list[].metadata

Metadata about the item from your Items dataset.

item_list[].promotion_name

The name of the promotion that included the predicted item.

item_list[].reason[]
item_list[].score

A numeric representation of the model's certainty that the item will be the next user selection. For more information on scoring logic, see how-scores-work.

recommendation_id

The ID of the recommendation.

VARCHAR