Personalize search ranking processor

The personalize_search_ranking search response processor intercepts a search response and uses Amazon Personalize to rerank search results according to their Amazon Personalize ranking. This ranking is based on the user’s past behavior and metadata about the search items and the user.

To use the personalize_search_ranking processor, you must first install the Amazon Personalize Search Ranking (opensearch-search-processor) plugin. For detailed instructions, see Installing and configuring the Amazon Personalize Search Ranking plugin.

Request fields

The following table lists all available request fields.

FieldData typeDescription
campaign_arnStringThe Amazon Resource Name (ARN) of the Amazon Personalize campaign used to personalize results. Required.
recipeStringThe name of the Amazon Personalize recipe to use. Currently, the only supported value for this field is aws-personalized-ranking. Required.
weightFloatThe weight to use with rankings provided by OpenSearch and Amazon Personalize. Valid values are in the [0.0, 1.0] range. The closer the weight is to 1.0, the more weight is given to Amazon Personalize as opposed to OpenSearch when calculating the ranking. If you specify 0.0, OpenSearch rankings are used. If you specify 1.0, Amazon Personalize rankings are used. Required.
item_id_fieldStringIf the _id field for an indexed document in OpenSearch doesn’t correspond with your Amazon Personalize itemId, specify the name of the field that does. By default, the plugin assumes the _id data matches the itemId in your Amazon Personalize data.
iam_role_arnStringIf you use multiple roles to restrict permissions for different groups of users in your organization, specify the ARN of the role that has permission to access Amazon Personalize. If you use only the AWS credentials in your OpenSearch keystore, you can omit this field. Optional.
tagStringThe processor’s identifier. Optional.
descriptionStringA description of the processor. Optional.
ignore_failureBooleanIf true, OpenSearch ignores any failure of this processor and continues to run the remaining processors in the search pipeline. Optional. Default is false.

Example

The following example demonstrates using a search pipeline with a personalize_search_ranking processor.

Creating a search pipeline

The following request creates a search pipeline with a personalize_search_ranking response processor:

  1. PUT /_search/pipeline/my-pipeline
  2. {
  3. "description": "A pipeline to apply custom reranking from Amazon Personalize",
  4. "response_processors" : [
  5. {
  6. "personalized_search_ranking" : {
  7. "campaign_arn" : "Amazon Personalize Campaign ARN",
  8. "item_id_field" : "productId",
  9. "recipe" : "aws-personalized-ranking",
  10. "weight" : "0.3",
  11. "tag" : "personalize-processor",
  12. "iam_role_arn": "Role ARN",
  13. "aws_region": "AWS region"
  14. }
  15. }
  16. ]
  17. }

copy

Using a search pipeline

To search with a pipeline, specify the pipeline name in the search_pipeline query parameter. For example, the following request searches for comedies using the pipeline set up in the previous section:

  1. GET /movies/_search?search_pipeline=my-pipeline
  2. {
  3. "query": {
  4. "multi_match": {
  5. "query": "Comedy",
  6. "fields": ["GENRES"]
  7. }
  8. },
  9. "ext": {
  10. "personalize_request_parameters": {
  11. "user_id": "user ID",
  12. "context": { "DEVICE" : "mobile phone" }
  13. }
  14. }
  15. }

copy

For additional details, see Personalizing search results from OpenSearch (self-managed).